I have the following situation in my GIT repository. Someone had forgotten to make a pull in the master before doing his changes, and then commited on his local master. After that, for some reason he merged the origin/master into his local master and then pushed that. The result was that the origin/master kinda "switched places" with what was his local master. Am I making any sense? Here is an example:
BEFORE THE PUSH
x----x-----x----x----x----x----x-----x----x (MASTER)
AFTER THE PUSH
---------------------------------------------x---x (MASTER)
| |
x----x-----x----x----x----x----x-----x----x-------
That kinda messed up the repository, as all the history now seems to have been on a branch.
After that, there were some new commits pushed to the new master, and then for a reason that isn't important right now, we decided we didn't want those, so we managed to drop the commits we didn't want, and at the same time restore de MASTER to its old place. Like this:
BEFORE
---------------------------------------------x---x---x---x---x (MASTER)
| |
x----x-----x----x----x----x----x-----x----x-------
AFTER
(2)
---------------------------------------------x---x---x---x---x--
| | |
x----x-----x----x----x----x----x-----x----x-----x----------------x (MASTER)
(1) (3)
As you can see, now that commit that was donde by the guy who forgot tu pull has been merged into what originally was the master. This was achieved like this:
git checkout <HASH OF COMMIT MARKED AS (1) >
git checkout -b refactor_master
git merge --no-ff <HASH OF COMMIT MARKED AS (2) >
git push origin refactor_master
git merge --strategy=ours mastergit checkout master
git merge refactor_master
git push origin master
That efectively made the changes incorporated by those commits dissapear from the master, and also turned the master to what it used to be. However, I now have a "branch" that should not have existed. In fact, the last commit, marked as (3), does not make any changes. It only "switches" the masters. Is there any way to make those commits dissapear?