I work on a project where we have several releases in progress at any given time. As PRs are merged, those changes are also auto-merged into "downstream" releases, e.g. a PR into release/10.ABC
gets downstream merged into release/11.XYZ
and release/12.001
. Here, release/12.001
is "downstream" of release/10.ABC
and release/11.XYZ
.
In release/12.001
, our technology changed, and dir_a/api.py
was moved to dir_b/api.py
. Now, as PRs are being merged in to release/11.XYZ
based on the former technology, we're getting downstream merge conflicts.
We'd like the repository to not block downstream merging because of these falsely perceived merge conflicts every time an upstream branch changes the old implementation.
In retrospect, we should have done this:
- remove
dir_a/api.py
and commit - add
dir_b/api.py
and commit
Unfortunately, this was not done; they were added and removed in the same commit. Is there any way to retroactively perform equivalent actions (preferably without rewriting former commit history), e.g. from this commit forward, mark these files as separate for future merges?
Note
Git doesn't store the fact of whether it's moved vs deleted and added, and instead it relies upon similarity detection; see How to make git mark a deleted and a new file as a file move? and all of its linked questions for more information about the opposite issue: how to force git to recognize a rename.
Our issue is that we intended for something to be an add and a remove of separate files, and git is detecting similarities we'd prefer it not to detect going forward. We're not interested in changing the global threshold on the similarity index for git merge, the problem is limited to one file.
Does git have a file-specific flag which can impact merge strategy that might be useful for us in preventing merge conflicts from upstream branches?
Of course, I realize that git has no concept of upstream / downstream branches, only commits, but I'm not sure how better to state the question.
If this is not possible, then we'll just have to resolve merge conflicts on a one-by-one basis as upstream PRs come in.