I have a real mess on my hands but I am sure there will be a trick to fix it.
We used to have a developer who would keep a separate branch for every software 'version' which was awful as a bug fix would have to be cherry picked onto every branch. For the repo in question there were 6 concurrent branches.
In reality, various bug fixes occurred on each branch. So every branch had something quite different on it. That developer had now left and I would like to merge all the branches back onto master. I did the following (two feature branches illustrated for clarity):
M0 - M1 - M2 - - - - - - - - - - M3* - M4 - M5 - M6
\ \ / /
\ fB - fB - fB - fB - - - - - - - - - - /
fA - fA - fA - fA - - - - - - - - - - - - -
This looked OK, but there is one major problem. In commit 'M3*' every file in the repository was committed as the file permissions had changed. No functional changes occurred to the files. This commit happened more recently than the commits in the feature branches, so when I merge, this is the version that gets chosen.
All of the above badness has been pushed to the remote.
I would like to merge all the changes (including the changes in M2 and M4) but ignore the changes in M3*.
How could I go about this?
One simple way to do it without rewriting neither local nor remote history would be to revert commit M3
It would not delete or change M3
in any way, just create a new commit (let's call it M7
) containing the exact opposite changes brought by M3
:
git revert M3
M0 - M1 - M2 - - - - - - - - - - M3* - M4 - M5 - M6 - M7
\ \ / /
\ fB - fB - fB - fB - - - - - - - - - - /
fA - fA - fA - fA - - - - - - - - - - - - -