Question

The way our git repository and workflow is configured is that we have a branch called "stream-head" which is the mainline repository, and then create separate branches for each ticket that we are committing work on. I often find myself wanting to compare the ticket# branch that I am on, to the stream-head mainline branch to see the changes I have made.

I have found this command useful to open Kdiff3:

git difftool stream-head:<path_to_file> <ticket_#_branch>:<path_to_file>

Example:

git difftool stream-head:./food/fruit/apple/gala.c ticket12345:./food/fruit/apple/gala.c

The only problem with this is the files are often buried under many sub directories as you can see in the example above. Tab-completion is not available when typing this command, so it is very cumbersome and easy to make a mistake.

How can I easily do a visual diff across branches without having to type the entire path to the file manually?

Was it helpful?

Solution

Here is an alternative specification that might give you automatic tab-completion:

git difftool stream-head ticket12345 ./food/fruit/apple/gala.c

If you find yourself executing this repeatedly for many files in your development branch to see differences, it might be more efficient using the --dir-diff option instead. Since you appear to be using Kdiff3 as your diff tool, this should fire up a window that contains all file differences between the two branches that you have specified. For example:

git difftool --dir-diff stream-head ticket12345
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top