One file not showing in the newly created branch of git

Viewed 43

I have 4 files inside a folder. I started committing them one by one to "patch-1".

I used

git add "filename1"
git commit - m "comments"
git branch -m patch-1
git push -u origin patch-1

the file was added to staging area, eventually I pushed the file but it does not show in the pull request

Then I created a new branch "dev" in the repo and deleted the "patch-1", now all the other file are showing in the folder except filename1.

What I mean to say is I committed one file to patch-1 branch in a repo but the commit did not show up in the repo, so I made another branch dev and deleted patch-1. Now in the new branch I see only three file out 4, (the one I committed is not showing up)

When I change the branch in git bash, it shows there.

1 Answers

The sequence is:

  • Clone the repo: git clone URL-OF-THE-REPO
  • cd into it, and create your branch: cd REPODIR; git checkout -b patch-1
  • At this point, git bash will show you to be in branch "patch-1"
  • create filename1: use your editor of choice
  • Add filename1: git add filename1
  • At this point, git status will show the new file filename1.
  • Commit: git commit -am "comments"
  • Push: git push origin patch-1

At this point, you will have uploaded (pushed) filename1 to your origin. But it will only be visible in the "patch-1" branch. If you want to have it in your master branch, you will need to merge the branch into it (pull request).

FYI good quick reference: https://rogerdudler.github.io/git-guide/

Related