Git - coworker somehow overwrote my entire commit while resolving a conflict

253 views Asked by At

This is what he says he did:

There was a merge conflict so I chose mine.

What I'm seeing is that my changes are totally gone. The commit is there, but if I go on GitHub and click 'history' for the file, there's nothing showing that my changes were ever there. I found the guilty commit but all it says about it is:

Conflicts:
        .../<file>.js

What I saw that looked fishy is the commit is titled:

Merge remote-tracking branch 'origin/development' into devenv

But development is our remote branch, so I'm guessing he merged to his local branch, goofed it up, and then accidentally pushed his local branch to development.

Would this cause the behavior I described? Any ideas on a clean way to fix this?

Edit: So it looks like a cherry-pick fixed the problem, I still don't quite get how it got into this state though. I couldn't find any evidence of a force push (Git not Star Wars).

1

There are 1 answers

0
Nick Volynkin On BEST ANSWER

Nothing just disappears in Git. You can do one of the following:

  1. Undo the merge on development branch. Undo a Git merge that hasn't been pushed yet
  2. Cherry-pick your last commit (with all your contributions) from the history. How-to git backport (rebase/cherry-pick) an already merged branch