Assuming a commit graph as follows:
| (A) ---------> (B) ----------> (C) | ^ | (master)
You want to check master first and create a branch that indicates where master is located:
git checkout master git branch pointer master
It should now look like this:
| (A) ---------> (B) ----------> (C) | ^ | (HEAD, master, pointer)
Now that you are already on master , we will tell the master branch to move back one commit:
git reset master~1
Now master should be moved back one space, but the pointer branch is still in the last commit:
| (A) ---------> (B) ----------> (C) | ^ ^ | (HEAD, master) (pointer)
At this point, you can push master to the remote or anywhere, and then quickly move it back to the pointer branch. You can kill the pointer branch at this point:
git push origin master git merge
The final:
| (A) ---------> (B) ----------> (C) | ^ ^ | [ origin/master ] (HEAD, master)
C0M37 Aug 29 '14 at 18:43 2014-08-29 18:43
source share