tags:

views:

51

answers:

1

From here, http://cheat.errtheblog.com/s/git, I think I can recreate a branch in my local repository by

$ git branch mytestbranch
<then I can may changes as my experimental>

My question is how can

  • I forget all the changes I made in the 'mytestbranch' branch? and switch back to my original 's stage/version of my repository?
  • I keep the changes I made and move every thing to my 'main' branch?

Thank you.

+3  A: 

If you want to forget everything that you did in mytestbranch and you don't want to use any of those changes, you don't have to do much, just switch to master and delete the branch:

git checkout master
git branch -D mytestbranch

If you want to merge all the changes you made in mytestbranch just do merge:

git checkout master
git merge mytestbranch
git branch -d mytestbranch

The difference between git branch -D and git branch -d is that the former can delete branches that have not been fully merged into HEAD.

Igor Zevaka