Solving the git Merge nightmare

I recently started using git at my new job. I have very little experience with git. And Obviously I made mistake. This it was big mistake. I just took down out beta site :). More over I created new branches from the corrupted master branch. My other colleague also use that branch. In the morning I got email from CTO that beta site is not working and I added some code on some program that I should not touch. BTW my CTO is awesome who fixed the whole mess and was cool about it.

Let me tell you what I did. After working on a branch. I switched to main branch and I forget that I was on main branch. So I changed some files. Then I pull the code form my forked repo.

git pull upstream master

then git told me that there were some conflicts. I never resolved any conflict before – so it was quite daunting experience. Long story short – I messed up and kept “<<<<<<<:", "=======", "HEAD" & ">>>>>>>” in js file, css file and in some perl program. Then I merge the branch i worked in master branch. See what I did.

So my CTO sat down with me – basically he did everything. First he reset to last commit which was just before my virus merge.
First he went to the main branch and reset the head. Then he pick the commits that was committed after my virus commit. In this way the branch was clear of my bug

git reset --hard commithash
git cherry-pick commithash

About Zakir Hyder

This entry was written by .

13. May 2013 by Zakir Hyder
Categories: git | Tags: , , | Comments


  1. […] my git nightmare, I decided to make post like Things I […]