0
votes

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

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
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
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