25

Is there program that allows output of a git-diff command to be explored in a GUI?

What i am looking for is something similar to the how SmartGit displays its view of the differences between the working copy and the HEAD. Where each of the files that are different to the HEAD are displayed and the diff for the focused file is displayed.

I am not sure if it is possible to make SmartGit display the output of a "git diff" command.

alt text

Frank
  • 1,003
  • 2
  • 13
  • 19
  • I don't quite understand how what you're asking for is different from what you've shown. Is there some reason you can't use SmartGit? Or are you asking about alternatives to SmartGit? – Greg Hewgill Nov 11 '10 at 23:32
  • i want to see any git-diff output in a similar style to the image. SmartGit only essentially shows the working copy to HEAD diff. – Frank Nov 11 '10 at 23:38
  • SmartGit's diff display looks very similar to [meld](http://meldmerge.org/), which can be run standalone. – endolith Aug 21 '12 at 16:23
  • I have a similar requirement. We use `sshfs` to edit code on a staging server. Trying to run any git command over `sshfs` is abysmally slow. But git commands executed on the server when logged in over ssh work as normal, of course. What I want to do is run `git diff` on the server and capture the output in a file, e.g. `git --no-pager diff > changes.diff`, get a copy of that file locally via `sftp` or `scp`, and view `changes.diff` in a GUI like `meld`. Rather than running `git diff` or `git difftool` over `sshfs`. Anyone? – drkvogel Aug 28 '18 at 16:41

9 Answers9

17

Starting with git v1.7.11, you can use git difftool --dir-diff to perform a directory diff.

The answer that follows applies to git installations older than v1.7.11.


As mentioned by others, git difftool may be used to open your diff in a GUI. However if you have multiple files with changes, it will open a separate instance of the GUI for each file.

I wrote a script to work around this "feature" and allow all the files to be opened in a single GUI instance. You can find the git diffall script on GitHub.

Also, you may be interested in this related SO question:

git difftool, open all diff files immediately, not in serial

Community
  • 1
  • 1
Tim Henigan
  • 60,452
  • 11
  • 85
  • 78
10

If you want a human friendly UI, but still want to stay within your terminal, you can use:

git tui diff [args...]

!demo

Install

git-tui

sudo snap install git-tui

https://github.com/ArthurSonzogni/git-tui

Disclaimer: I am the author.

It is an open source project under the MIT license.

ArthurS
  • 350
  • 3
  • 5
  • This looks cool - can it be installed on a Mac? – Jeff Wright Jun 29 '21 at 21:18
  • Really cool. But can I use it with windows? I mostly use git bash in windows 10 for git, but I don't think snap works in such an environment. Thanks for such a great tool – API Aug 17 '21 at 09:12
  • @AlexFeng There are no strong reasons this wouldn't work on Windows. This is multiplatform. However, this requires some work to provide windows binary and testing. I can configure the CI to build and produce windows's executables. Is there anyone wanting to test and tweak it to support windows? – ArthurS Sep 01 '21 at 16:14
  • @ArthurS Thanks for your kind reply. Currently, I am using the default difftool that came with git bash for windows, and it provides a similar diff-comparison, though a bit uglier. – API Oct 03 '21 at 09:46
  • 2
    Progress have been made. The Windows and Mac binary are built. See: https://github.com/ArthurSonzogni/git-tui/issues/2 – ArthurS Oct 15 '21 at 13:19
6

Beyond Compare does this nicely - no configuration changes needed to the basic 'git diff' command which creates the .diff file. Beyond Compare shows all the files, that are referenced in the .diff file in a file tree view and the diff for each file as you select it.

In Beyond Compare, use the 'Tools -> View Patch' menu option

russellg
  • 61
  • 1
  • 1
3

Here is a site to do this - Diffy - A tool for sharing diffs.

There you can paste your diff text output, or upload a file containing the diff output, then it automatically shows the diff on a tree explorer. It's good for scenarios where you don't have any permissions to install programs on your machine (thanks, employer!).

Diego Victor de Jesus
  • 2,575
  • 2
  • 19
  • 30
2

JetBrains products like IntelliJ, GoLand, PyCharm etc all have the diff tool built-in. If you want to have a diff between current commit vs previous commit you just right click on the left of code line and turn on Annotation, then click any annotation you will view the all the files diff.

Furthermore, if you want to view the diff of current branch vs another branch like origin/master you can do that too. You just right click on the root directory and hover over to Git menu and you click Compare with Branch and select master you view all the diffs together just like viewing a Pull Request on Github.

Peiti Li
  • 4,634
  • 9
  • 40
  • 57
  • Wonderful! I have been using Fork and missing the "Show Diff With Working Tree" feature. Glad you found it in the Jetbrains IDEAs – A.J. Aug 04 '20 at 14:06
1

I know you're looking for a GUI rather than a TUI, but vi/vim/vimdiff will display a diff file with syntax highlighting: view changes.diff, where changes.diff was created by doing git --no-pager diff > changes.diff. I've been looking all over the place for a GUI that will read one of these files, to no avail - meld has a --comparison-file=COMPARISON_FILE option, but whatever that comparison file format is, it doesn't work with regular (unified) diff output.

drkvogel
  • 2,061
  • 24
  • 17
0

git diff has a --ext-diff option that pipes the diff output to an external diff program. Popular open source diff programs that are known to work with Git include kdiff3 and Meld.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
0

git difftool will run all popular ones like meld, tkdiff, etc. Also for merges you can run git mergetool.

KiRPiCH
  • 379
  • 3
  • 6
0

I'm not sure I've understood your question correctly, but apparently in the next version of SmartGit (2.0, currently available in alpha), you can use the log window to do diffs between arbitrary commits - I haven't tried yet though.

Benjol
  • 63,995
  • 54
  • 186
  • 268