I have my git master branch, then i created a new branch to work on a new, long-term feature, and i've added and committed changes to this new branch, and pushed them to github. I then pulled these changes from the git repository onto my DEV box from the new branch. Now i want to git checkout master
so i can add/commit a one-line hotfix. But on my DEV box (and in my working directory) when i git checkout master
, the files in the file-system still reflect the changes i made on the feature branch. I thought by checking out the master, it would revert my working directory (and the directory on DEV) back to the way it is in the master branch, but it doesn't appear to be doing that. I have verified in GitHub that the new-feature changes are in the new branch, and i've verified thru GitHub that the master does NOT have those changes and is the way i had left it.
Is there another step (other than git checkout master) i must make to change the files on the DEV box and my working directory to reflect what is in the master branch? i have also tried git pull origin master
, with no luck.
When i do git status
, it says i'm on master, and it also says "Your branch is ahead of 'origin/master' by 12 commits".
I've been using this website and followed it's commands: https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging ...but it doesn't seem to be reverting my working directory to the way it was before my feature commits.
any help is much appreciated, thanks.
CodePudding user response:
It sounds like you made commits to your local master
branch while developing the feature, so it is now ahead of the remote server. To checkout origin/master
, you should use:
git checkout origin/master -B master
Portion origin/master
indicates that you are checking out the master
branch from the remote and -B master
indicates that the local master should be updated to point origin/master
.