I would like to set up a Git repository with a custom merge driver, and then disable rename detection when merging.
The problem is that, if I use the default recursive strategy, I cannot disable rename detection, and if I use the resolve strategy (not ideal, but good enough), the merge driver is ignored.
Note that I would like to avoid rename detection even when the file contents perfectly match.
.git/config:
[merge "my"]
name = my merge
driver = my_merge_driver %A %O %B
[merge]
default = my
Attempts:
$ git merge -X rename-threshold=200% # Equivalent to 100%
$ git merge -s resolve # Custom driver ignored
$ git --version # git version 2.2.0-rc0
Resolve is generally considered a safe and fast merge strategy. However, it can only resolve two heads—your current branch and the one you're pulling from—with a three-way merge algorithm. Resolve is suitable for criss-cross merge situations as well as “regular” merges where the merge history might be complex.
But, instead of using a merge commit, rebasing re-writes the project history by creating brand new commits for each commit in the original branch. The major benefit of rebasing is that you get a much cleaner project history. First, it eliminates the unnecessary merge commits required by git merge .
In the event that you require a merge commit during a fast forward merge for record keeping purposes you can execute git merge with the --no-ff option. git merge --no-ff <branch> This command merges the specified branch into the current branch, but always generates a merge commit (even if it was a fast-forward merge).
ort. This is the default merge strategy when pulling or merging one branch. This strategy can only resolve two heads using a 3-way merge algorithm.
As of Git 2.8.0.rc0, the merge-recursive algorithm now accepts an option "no-renames" (commit 4ce064d), so my problem is now solved by
$ git merge -X no-renames
Taking into account the use case you're planning for this, A good workaround would be to write the filename, along with the version number, in each file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With