0

A coworker accidentally merged dev into master and pushed. A few more commits were pushed before I noticed.

I pulled master in my local env

git pull origin master

I created a new branch to do some tests revert

git checkout -b prod

I reverted to the commit before the bad merge

git reset --hard <commitId> && git clean -f

The code is now good but the problem is when I try to merge in the new prod an old branch that has already been merged in dev. I get the message :

Already up-to-date.

Is there a way to fix this or we will have to copy the code from the old branchs into prod

user2942945
  • 469
  • 1
  • 7
  • 19
  • Does this answer your question? [How do I revert a Git repository to a previous commit?](https://stackoverflow.com/questions/4114095/how-do-i-revert-a-git-repository-to-a-previous-commit) – Calum Halpin Sep 22 '21 at 19:26
  • Note that your statement "I reverted to the commit before the bad merge" shows a `reset` command next, which in Git is different from `revert`. In English "revert" can mean "go back to where you were before", but in Git, "revert" means to make a new commit which does the exact opposite of the reverted commit, such that the sum total of the two commits is no changes. So `revert` and `reset` do very different things, in Git. – TTT Sep 22 '21 at 21:05
  • When you say "merge in the new prod an old branch that has already been merged in dev", are you referring to the branch that represents the commits you mentioned here: "A few more commits were pushed before I noticed." ? – TTT Sep 22 '21 at 21:11
  • The logical explanation is whichever branch you tested merging into your new `prod` branch, already was in `master` before `dev` got merged in. (Either that, or you didn't do exactly what you think you did.) Maybe you could try a "newer" branch that definitely isn't in `master` yet. – TTT Sep 22 '21 at 21:20

0 Answers0