Problem Statement:
I have 2 main branches: master(PROD) & dev(UAT). Whenever my team receives a change request on the application, we create a branch from master do our changes, and before merging the branch into master, we do "git pull origin master", so that our branch code must be in sync with master code.
At starting of February, my colleague merged a branch into master. But here the branch was not created from master. So the master got polluted. I reverted the changes but the revert was not proper. What I did was "git revert -m 2". After the revert commit, there are 3 merge commits on master.
I have the last commit id till where the master branch was not polluted. My main concern is that I want the master to be clean.
Questions:
Thanks in advance.
PS: I don't have any GUI tools.
What I did was "git revert -m 2". After the revert commit, there are 3 merge commits on master.
First of all, git revert
does not remove any commits. That is the whole point of git revert
. So if your complaint is that the merge commits are still there, that is normal and you should not be complaining about it.
On the other hand, it looks like you gave the wrong command. The way to revert a merge commit so that the incoming branch has no effect on the mainline branch is to say
git revert -m 1 <SHA>
In other words, you said -m 2
when you should have said -m 1
.
You have two choices at this point.
One possibility is to revert the bad revert, and then do a good revert.
The other possibility is just to reset --hard
back to the state of things before the bad merge(s) — but that is frowned upon if this is shared material, as it can make everyone else's life very difficult.