Created new branch by mistake and need to get to previous branch
I am relatively new to git and github. I made some changes on my master branch, and instead of doing "git开发者_JAVA技巧 add ." with my master branch and going through the process to push these changes, I did 'git checkout -b xyz'.
I am now on a new branch xyz but need to get to the master branch that I haven't done "git add ." on yet, and I need to push my old branch to github. How can I go back to the master branch that I haven't pushed yet?
What you have done is bascially creating a new branch and moving to that branch.
If you want to go back to the master branch you need to do:
git checkout master
And since you don't need the xyz
branch anymore you could also delete it:
git branch -D xyz
Finally, in order to push your latest changes to the master branch of your remote (which I suppose is called origin
) you need to do:
git add .
git commit -am "Your commit message"
git push origin master
Edit
Like I told you on one of my replies, I think you should take the time to read at least the first chapters of the Pro git book by Scott Chacon. It is really worth it and it will help you understand the basics of how git works.
精彩评论