Reputation: 579
Previously I made a mistake of not using git-mv when branching out, and now I have an issue merging the branch back.
After git-merge, when I run git-status I get:
....
deleted: __init__.py
deleted: __main__.py
deleted: config.py
....
new file: mose/__init__.py
new file: mose/__main__.py
new file: mose/config.py
new file: mose/elliptic_fibration.py
....
deleted by them: elliptic_fibration.py
But I want the files with the same name to be marked as 'renamed.' Is there a way to achieve that?
====
added to elaborate my situation:
The reason that I want them to be considered to be 'renamed' is because I want the changes my collaborators will make on those files in a different branch to be correctly incorporated when they merge their branch into the master branch.
If I tweak the merge threshold when merging my branch into the master branch such that the files appear to be 'renamed,' will it work as I expect when my collaborators try to do the merge without any additional work?
Upvotes: 0
Views: 164
Reputation: 332736
Git doesn't actually track moved files; it just detects when you do a diff, log, or blame if there's a deleted file and a new file with the same, or similar, contents, and treats that as a rename. There are a few options to these commands that determine exactly how similar the files need to be in order to be considered renames of each other (and how hard it looks), such as -M
to find renames, -C
to find copies, and --find-copies-harder
.
You won't necessarily see this in git status
, but it should show up if you look at git diff --stat -M
(or possibly git diff --stat --cached -M
).
When doing the merge, it will also try to detect renames, and merge intelligently based on renames, but you can tweak this behavior by passing the -Xrename-threshold=<n>
option to set a different threshold for how similar files need to be before it considers them renames.
Upvotes: 1