Git: Undo all changes to a diverging local branch

I have a local section branch that is tracking the remote branch. For an argument, say, commit history looks like this:

A--B--C--O1--O2--O3 (origin/phobos) \ L1--L2--L3 (phobos) 

phobos looked at the relative commit history, now I want to undo all the changes in the local phobos branch and return it to a direct copy of origin/phobos so that the local history looks like this:

 A--B--C--O1--O2--O3 (phobos origin/phobos) 

I really don't need local changes in the phobos branch, and I really don't want merges to appear in the original repository. (So ​​just merging is not what I mean.)

It seems like it should be very simple, but my google-fu didn't help me. How to do it?

+75
git
Mar 01 '10 at 19:58
source share
2 answers

Delete the branch, then recreate it:

 $ git branch -D phobos $ git checkout --track -b phobos origin/phobos 
+58
Mar 01 '10 at 20:03
source share
 git checkout phobos git reset --hard origin/phobos 

This tells Git to reset the phobos chapter the same commit as origin/phobos , and update the working tree to match.

+210
Mar 01 '10 at 20:16
source share



All Articles