2

I create a file foo in the git repository on branch master.

Then, I create a new branch dev, using git checkout -b dev.

On the branch dev, I rename it to bar using git mv foo bar.

After that, I change something in the foo and commit it.

But, when I checkout branch dev and git merge master, git doesn't merge it automatically for me and asks me to merge it myself.

So, is foo the ancestor of bar after I execute git mv? Is there any way to let git merge automatically?

Wenhao Ji
  • 5,121
  • 7
  • 29
  • 40

1 Answers1

2

As mentioned in "git merge with renamed files", you should try and adapt the rename threshold:

Since git 1.7.4, you can specify the rename threshold for merge as

git merge -X rename-threshold=25 

in order to control that a similarity of 25% is already enough to consider two files rename candidates.
This, depending on the case together with -X ignore-space-change may make rename detection more reliable.

Still from Tilman Vogel, the script git-merge-associate can help restore the association between two files (one being the renamed version of the other), when the merge doesn't detect the rename.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250