Diffing between two entire directories/projects in hg or git?

Related searches

I inherited a project originally stored in CVS with all the revisions. I made quite a few edits, and I'm trying to compare all the changes I made in the original directory, in regards to new files added versus the old ones.

Is there some sort of utility for hg/git where I can do a tree diff, or something of that nature? So that say, there's a mark between newly added files, deleted files, am I asking for too much?

git diff does exactly that. but it only works for git projects.

hg diff, svn diff pretty every version control system can diff directory trees

Diffing between two entire directories/projects in hg or git?, Answer. git diff does exactly that. but it only works for git projects. hg diff , svn diff pretty every version control system can diff directory trees� Stop trying to use Git/Hg tools for this. The diff tools provided there are to show you what changed between commits, not to compare different files. Download WinMerge, and use it to compare the two directories you talked about in your original question. It will allow you to navigate through the tree, will show you which files have differences, and will allow you to view differences between one pair of files at a time.

To simply create a diff patch in git's diff format from two arbitrary files or directories, without any fancy repository stuff or version control:

git diff --no-index some/path other/path > some_filename

Jakub Narębski's comment on knittl's answer hinted at the answer... For simplicity's sake, that's the full command.

The > part creates a file and redirects the output to it. If you don't want a file and just want the output printed in your console so you can copy it, just remove the > some_filename part.


For convenient copying and pasting, if you've already cded to a directory containing the original directory/file named a and the modified directory b, it'll be:

git diff --no-index a b > patch

Solved: How to diff two folders in two different repo?, Solved: I have created two repo named as 'bb201repo' and 'bb301repo' Now I have added two folders with files in these two repositories. Now in both. Now I want to see the diff between all files containing in the both folder. No any changes made in files after Stop trying to use Git/Hg tools for this. The diff tools provided� However git diff detects this by default and can create patches that are applied with git apply in a similar way to patch. You can use it on arbitrary directories, not just repos, with --no-index (see Diffing between two entire directories/projects in hg or git?

From git diff manpage:

git diff [--options] [--] [<path>...]

[...] If exactly two paths are given, and at least one is untracked, compare the two files / directories. This behavior can be forced by --no-index.


If you want to compare two versions (e.g. two tagged releases, or two branches) in two different repositories, you can use trick described in GitTips page on Git Wiki, under "How to compare two local repositories".

Assuming that you are inside one repository, and second repository is in /path/to/repo, so its GIT_DIR is /path/to/repo/.git if it is non-bare repository, you can something like the following:

$ GIT_ALTERNATE_OBJECT_DIRECTORIES=/path/to/repo/.git/objects \
   git diff $(git --git-dir=/path/to/repo/.git rev-parse --verify A) B

where A and B are revisions you want to compare. Of course you can also specify path limiter in above expression.

Explanation: GIT_ALTERNATE_OBJECT_REPOSITORIES variable can be used to make git commands concatenate object database of the two repositories. git --git-dir=... rev-parse ... is used to turn name (extended SHA-1 expression) in repository given as parameter to git-dir option into unique SHA-1 identifier. The $( ... ) construct puts result of calling given command in command line. git diff is used to compare two revisions (where one is from alternate object repository).

Alternate solution would be to simply import other repository into given repository, using git remote add (and git fetch). Then you would have everything locally, and would be able to do comparision inside single repository.

How to compare two directories thoroughly without git?, diff -Naur dir1/ dir2/. Pretty useful for submitting software patches, incidentally: diff -Naur orig/ patched/ > my_changes.diff. git diff [<options>] [--] [<path>…. This form is to view the changes you made relative to the index (staging area for the next commit). In other words, the differences are what you could tell Git to further add to the index but you still haven’t.

Is there some sort of utility for hg/git where I can do a tree diff... [s]o that say, there's a mark between newly added files, deleted files... [emphasis added]

Yes. We can git diff the current directory against another directory and...

...mark the added, deleted, and modified files:

git diff --name-status --no-index ./ path/to/other/dir

...show only added files:

git diff --diff-filter=A --name-status --no-index ./ path/to/other/dir

... show only deleted files:

git diff --diff-filter=D --name-status --no-index ./ path/to/other/dir

...show only modified files:

git diff --diff-filter=M --name-status --no-index ./ path/to/other/dir

See also: https://git-scm.com/docs/git-diff

Diffing between two entire directories/projects in hg or git?, Is there some sort of utility for hg/git where I can do a tree diff, or something of that nature? So that say, there's a mark between newly added files, deleted files,� The only way to make this usable is to rename one of the .git directories. this reduces to two lines pages of differences that don't matter. Been there, done that, came here looking for a better answer. – hildred Oct 10 '16 at 22:02

It's not git-specific, but as a general diff utility for Windows, I really like WinMerge.

Difference between folders, To compare 2 files, we use the diff command. How do we compare 2 directories? Specifically, we want to know what files/subdirectories are common, what are� scenarios. Projects that are diligent about tagging can use Compare View to generate a comprehensive list of changes between any two releases. A few examples in the wild: Changes between the Sinatra 0.9.4 and 1.0.a releases (pictured above) Changes between the Rails 3.0 beta and current master; Changes slated for the next version of Git

Now Git knows that if it tries to do a diff between two snapshots, and any of the files end in .docx, it should run those files through the “word” filter, which is defined as the docx2txt program. This effectively makes nice text-based versions of your Word files before attempting to diff them.

For example, you might want to move a directory from an existing project's repository into a new repository of its own. When refactoring, it is good practice to retain in the new project all the source history from the old project. The procedures on this page explain how to move a directory from one repository into another and retain the history.

nbdime Jupyter Notebook Diff and Merge tools. nbdime provides tools for diffing and merging of Jupyter Notebooks. nbdiff compare notebooks in a terminal-friendly way; nbmerge three-way merge of notebooks with automatic conflict resolution; nbdiff-web shows you a rich rendered diff of notebooks; nbmerge-web gives you a web-based three-way merge

Comments
  • stackoverflow.com/a/12123669/1815624 git diff master..yourbranch path/to/folder
  • Can you expand on how I can use git diff? I created two separate git projects, how can I compare them now? I'm still relatively new to VCSing.
  • you only need one project. commit all your files, make your changes, commit again. you can then do git diff HEAD^..HEAD, which diffs your latest version against the one before it
  • Ok - I guess I got what I wanted because I'm seeing a ton of results, can you recommend a nice GUI?
  • try gitk and git gui, gitk visualizes project history, git gui allows you to prepare commits and such
  • Actually git diff can compare arbitrary files/directories; you might need to use its --no-index option
  • To use git diff options, add the options before the paths. E.g. git diff --name-status --no-index some/path other/path works with the --name-status option.
  • use --binary for binary files, otherwise the patch will just say "Binary files differ"
  • From git-diff manpage: "You can omit the --no-index option when running the command in a working tree controlled by Git and at least one of the paths points outside the working tree, or when running the command outside a working tree controlled by Git."