There is a commit on master branch which I need to make some changes to.
Here's some history of what happened:
- I was working on some code, and merged this to master
- I created a new branch
- Someone else branched from master themselves, made changes and then merged to master
- In doing so, they have modified parts of the code which they should not have done. This is the core of the problem.
- Part of the work they committed should be on master (most of it in fact) however a small number of the changes should not have been merged.
- I continued working
- Now: I cannot merge to master myself, because not only will my code break in doing so, but some of my work will be lost, because the other person who has committed their changes has undone some of my work in the process.
- In theory, I could merge to master, and manually revert their changes by comparing code side-by-side as it was before they committed, or by inspecting the changes made during their commit.
- However, I believe there might be a better way. If I was able to edit the history of master (which for obvious reasons I cannot - at least not without upsetting a lot of people) then I would do an interactive rebase, focusing on this commit. But I can't do this.
- The "guilty commit" is now several commits down in the commit stack on master, as other people have committed work since this time.
What is the best approach here? I have never been in this situation before because I never worked in an environment where anyone could commit work without having it approved first.
I am of course aware that whatever I do here, I will have to do some level of manual work to make all of the new commits compile. It seems the longer I leave the situation the worse it will be to fix.