Assuming a commit graph like so:
| (A) ---------> (B) ----------> (C)
| ^
| (master)
You want to first checkout master
and create a branch that points to where master
currently is:
git checkout master
git branch pointer master
Should look like this now:
| (A) ---------> (B) ----------> (C)
| ^
| (HEAD, master, pointer)
Now that you're already on master
, we'll tell the master
branch to move backward one commit:
git reset master~1
Now, master
should be moved back one space, but the pointer
branch is still on the most recent commit :
| (A) ---------> (B) ----------> (C)
| ^ ^
| (HEAD, master) (pointer)
At this point, you can push master
to a remote, or where ever, then fast forward merge it back up to the pointer
branch. You can kill the pointer
branch at that point :
git push origin master
git merge --ff-only pointer
git branch -D pointer
Final :
| (A) ---------> (B) ----------> (C)
| ^ ^
| [ origin/master ] (HEAD, master)