Rob Lacey

Brighton, UK - contact@robl.me

Software Engineer specialising in Ruby on Rails. I do occasional freelance work, I love working for SARD JV Ltd, they are awesome and give me my pocket money every month. By all means dangle a carrot.


The scariest day of my life. Tainted master branch

You wake in a dark room and someone has only gone and tainted your master branch by merging in multiple commits spanning weeks of work. We can’t possibly unpick 100+ commits, what the hell even were they? But we need master back as it was.

We can however, reset our master to a particular commit in the past that we trust.

git checkout master
git reset --hard <somehash>
git push --force origin <somehash>:master

Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:somerepo/someproject.git
 + <someotherhash>...<somehash> <somehash> -> master (forced update)

There were tears of joy and shaky hands, but it was fine.