OMG! I just pushed the wrong branch…

Today I’ve done a lot of rebasing with a series of patches that I needed to push to the master branch of some project. The patches originated from a branch named injector and I prepared the merge in another branch named injector-merge. When it came time to merge my branch back into master I should have written :

git merge injector-merge

But instead I wrote :

git merge injector

Damned auto completion ! Huh… That wouldn’t be so bad if only I hadn’t pushed that to upstream too… So I had to get rid of my master branch and replace it upstream as quickly as possible before anybody could clone or pull from it. By chance this is a fairly new project and I guess nobody cloned or pulled in such a short amount of time (this whole thing lasted no more than one minute or so). So I moved my master branch and replaced it with the injector-merge branch and pushed-force everything.

git checkout master
git branch -m oldmaster
git branch -m injector-merge master
git log

Hum… Everything seems to be in order! Now push it back!

git push -f origin master

No complaining so far? Right! Well from now on I will call the merge branches merge-* instead of *-merge.