Merge / diff tool that can show authors (supports guilt or annotation) in versioned files

When merging files, it will be useful (like me) to show the author of each line. Is there any comparison or merge tool supporting this?

+7
source share
3 answers

The nested gitk tool is not really a merge tool, but it shows conflicting lines with red and blue and "+" in front, and you can Rightclick → "Show the origin of this line" on any of them to go to the commit that entered line:

Screenshothot

You can run your mergetool or just a text editor with parallel parallel parallel

+2
source

So what you really want is a tool that can easily identify your changes compared to other changes in the merge conflict, rather the author of each line (what would it mean), right?

If I understand you correctly, I have relatively good news: it can be done with git + kdiff3. For merging, you can simply use git mergetool (which you can configure to use kdiff3). But it is not supported initially if you get a merge conflict when performing an interactive reboot, so this requires several manual scripts.

Instead of compiling my own example of a simple conflict merge, I will use http://www.gitguys.com/topics/merging-with-a-conflict-conflicts-and-resolutions/ as the basis. Follow this page until the git merge test . After merging the command, I deviate a little from this example by running different commands (but basically do the same job). First I will do all the basic steps.

So, we have a merge conflict, and git inserted content from both providing sources in a file in this format <<<<<<<...>>>>>>> , which I really don't like at all, and never consider even looks at him. Instead, I use my favorite merge tool, kdiff3.

First we need to find which versions will be involved.

 $ git ls-files -u 100644 b0ed415d15862ac5582b51e4de65528e86934cd2 1 README 100644 56300e3ac4e4521c3500618a301bb2ab2d6a52f5 2 README 100644 9585db7d9c2d9ca05075f67a878f2554886d7b1a 3 README $ 

I deceived this information, which we can do in three ways:

 $ git cat-file blob b0ed415d15862ac5582b51e4de65528e86934cd2 > v1 $ git cat-file blob 56300e3ac4e4521c3500618a301bb2ab2d6a52f5 > v2 $ git cat-file blob 9585db7d9c2d9ca05075f67a878f2554886d7b1a > v3 $ kdiff3 -o merge_result v1 v2 v3 & [2] 18394 $ 

Which gives the following view, where you can choose from which ancestor you want to merge.

kdiff3 screenshot

Afterwords (if you are satisfied with the result of the merger) you need

 $ rm v1 v2 v3 $ mv merge_result README $ git add README 

All of the above steps are manually performed automatically with git mergetool . So why show it all? Good, because if you get the corresponding conflict during git rebase -i , then it should be done this way (before running git rebase --continue ).

In this small example, there is only one conflict, so it does not show a more typical case when many lines are automatically resolved, which allows you to simply manually resolve which were not performed automatically. A more real life example might look like this:

kdiff3 screenshot

Note that as a result of the merge, you now clearly see the beginning of C lines that were automatically resolved. I think this is what you asked for when you asked for an author for each line, right? This information is completely absent in the text <<<<<<<...>>>>>>> (and it is difficult / impossible to determine that you must update the printed line in the hello function).

I can not recommend kdiff3 highly enough. Using a graphical merge tool like this, compared to some lines from both sources, mixed inside a line in a file, like using an excavator compared to spade .

+1
source

Not. And, I think, never will be - when we merge, we think about the content, not about authorship

-5
source

All Articles