git difftool to give directory compare?
Asked Answered
S

2

36

Is it possible to get the git difftool command to open a directory compare between the changed files and the staging/checked files?

So ideally, if 2 files have changed, they would be the only 2 shown, but within a directory compare.

I've read posts about getting git to give all file diffs in parallel, so tools like BeyondCompare has all the diffs in tabs, but im not happy with that!

One could pull a copy of the changed files from staging/checked in files into a temp folder, and then open that up. Is that the only option?

Spherulite answered 21/1, 2010 at 23:45 Comment(2)
The answers I got on my (similar) question might help you: stackoverflow.com/questions/4248830/…Frieda
Since Git natively supports this behavior now, I voted to reopen this question. It is no longer a duplicate of https://mcmap.net/q/12823/-directory-comparison-of-git-branches/3092298.Gibbeon
B
53

Update June 2012 (2 and an half years later):

This (comparing directories instead of file-by-file) seems to be soon available:
See [ANNOUNCE] Git 1.7.11.rc1:

"git difftool" learned the "--dir-diff" option to spawn external diff tools that can compare two directory hierarchies at a time after populating two temporary directories, instead of running an instance of the external tool once per a file pair.

See "Patch difftool: teach difftool to handle directory diffs"


Original answer (January 2010)

One could pull a copy of the changed files from staging/checked in files into a temp folder, and then open that up. Is that the only option?

Basically yes:

You difftool script would:

  • create 2 temp directories
  • defines itself as a diff tool
  • call git diff
    • which then call itself for file to diff
    • in that mode, the same script, for each files, only copy the two version to diff in the two temp directories
  • then go on and call diff tools (like beyondCompare or WinMerge) on the two temp directories

You have one first example in this question.

Bobbee answered 22/1, 2010 at 5:15 Comment(4)
Why 2 temp directories? Be best to compare the changed files with the git sandbox against the checked in source? Therefore its only the checked in files that have changed that need to be copied/got out into a temp dir? Also this is best as one might want to merge changes from the checkedin files back into the working sandbox. Does anyone have any indention to make this sort of support standard in git?Spherulite
See this answer for more: https://mcmap.net/q/12823/-directory-comparison-of-git-branchesBobbee
Link to nabble no longer works.Ketchum
@Ketchum Thank you for the feedback. I have restored the link.Bobbee
E
2

I always use --dirstat=files:

rudie@devver:virenze$ git diff --dirstat=files
   4.1% modules/custom/virenze_conversations/
   7.0% modules/custom/virenze_crs/
   8.3% modules/custom/

which means I've removed dirs virenze_conversations and virenze_crs in custom. (I don't know what the percentages mean...)

You can probably use all the normal diff options: --cached, branch name etc.

Endosperm answered 23/12, 2013 at 11:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.