Working with a Reverted Git Branch

A month back I submitted a massive Pull Request (20 commits, 30 files) with some code that I had only loosely tested and it wasn't ready for production (test cases weren't finalized and sandbox testing had only been on my localhost.) Long story short, it got merged and broke a lot of things.

Oops.

It was quickly reverted with git revert -m 1 the errors were logged and I was to work on it when I got a chance again. I switched to that branch, fixed the bugs and made a fresh PR with a few more commits only to find that the first 20 commits weren't there. FUCK! Somehow I needed to revert the revert!

For those visual learners out there, here is an attempt at my commit tree. The messed up commit is the merge that happened at 'C' and the reverted commit that undid my doing is 'K'

H--A--C--K
     /
 M--E

A few rainbows and butterflies later I commit some changes at 'B', 'R', 'O' and want to merge back at 'T' but the Pull Request does not contain commits 'M' and 'E'

H--A--C--K----A--T
     /          /
 M--E----B--R--O

A little googling led me to a nice write-up and explanation on reverting a git revert by the Greek God of Geek himself. For the shortened version

# fix your bugs in your feature branch
$ git commit -m 'fixed bugs in feat_poorly_tested_branch'

# create new branch tracking develop
$ git checkout -b fix_revert_the_revert -t develop

# revert the reversion commit grabbed via your git log
# to find commit try: 'git log | grep revert -A 5 -B 5'
$ git revert 1a2b3c4d5e6f7g8h9i

# checkout the original feature branch
$ git checkout feat_poorly_tested_branch

# merge in the reverted develop
$ git merge feat_revert_the_revert

# handle merge conflicts and commit and PR
# profit

Comments !

About

Started writing one year ago, the day after heading out to travel around the world for a year without a cause.
Current Location: New York, New York

Previously:
Mexico City, Mexico
Tokyo, Japan
Hanoi, Vietnam
Vientiane, Laos
Phuket, Thailand
Kathmandu, Nepal
Rajastan, India
Kerala, India
Mumbai, India
Freetown, Sierra Leone
Koidu, Sierra Leone
Mombasa, Kenya
Nairobi, Kenya
Kigali, Rwanda
Rwinkwavu, Rwanda
Boston, MA

Latest Posts

Port Forward an old Airport Express

If Developers Took Steroids

We Need Elon Musk

Crossword Scraper

Git Conflicts in your Binary Files

Japanese Sidewalk Interfaces

Introducing Kickbacker

Real Life: Google Glass Done Wrong

Tux Trashcans

How Angry are your Developers?

A 500 Startups Model for the Art World

Unsubscribe from Black Friday/Cyber Monday

Copyrighting Art into Obscurity

Crack WiFi Passwords with aircrack

Using Sandy as an Excuse to Email Spam Customers