2

When merging, I often have modified code that is now "deleted". However it may have been moved somewhere else. How can I find out where?

Example: I change one line in a function foo defined in file A. Next, I merge with tree that this function is now moved to file B (and possibly also changed one line). In A the conflict markers say "this hunk was deleted".

sevo
  • 4,559
  • 1
  • 15
  • 31

2 Answers2

1

Assuming your branch is mybranch and the main tree is master, you could do git diff mybranch...master. This will show you all changes between the two branches using their nearest common ancestor commit as a reference point.

In the diff, you can search for your file to see what happened to it.

For more details see git help diff.

Yawar
  • 11,272
  • 4
  • 48
  • 80
0

There's a number of visual diff and merge tools which provide better visualization of diffs. These generally can show when a hunk of code was moved rather than deleted.

You use them with git difftool and this must be configured with which tool to use. There's a wide variety available. Here's an example using Meld.

enter image description here

Schwern
  • 153,029
  • 25
  • 195
  • 336