1

I am trying to merge 2 branches in git. The branches have chunks of nearly identical content, but in different files. Merge wants keep the content in both files leading to duplication.

Presumably one branch moved the content from one file to the other at some point. How can I find out when, in which direction and on which branch?

Daniel Mahler
  • 7,653
  • 5
  • 51
  • 90
  • In either of the branch one file content moved to another. `gitk path/to/file` will display the commits in which the files have been changed. First commit in gitk is the file creation/movement. By seeing the changes in that commit, we can understand when it moved and in branch which it moved. We have to do this in two branches which you mentioned. Link for gitk https://git-scm.com/docs/gitk – Dinesh Balasubramanian May 15 '18 at 04:48

1 Answers1

1

How can I find out when, in which direction and on which branch?

At least, starts with git log --follow ./path/to/file, and for each commit, display the branches including that commit: git branch -r --contains <commit>.

But keep in mind the --follow does not always work, as explained here.

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