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

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 … Read more

Highlight changed lines and changed bytes in each changed line

The diff-highlight Perl contrib script produces output so similar to that of the Trac screenshots that it is likely that Trac is using it: Install with: wget https://raw.githubusercontent.com/git/git/fd99e2bda0ca6a361ef03c04d6d7fdc7a9c40b78/contrib/diff-highlight/diff-highlight && chmod +x diff-highlight Move the file diff-highlight to the ~/bin/ directory (or wherever your $PATH is), and then add the following to your ~/.gitconfig: [pager] diff … Read more

Using ‘diff’ (or anything else) to get character-level diff between text files

Git has a word diff, and defining all characters as words effectively gives you a character diff. However, newline changes are ignored. Example Create a repository like this: mkdir chardifftest cd chardifftest git init echo -e ‘foobarbaz\ncatdog\nfox’ > file git add -A; git commit -m 1 echo -e ‘fuobArbas\ncat\ndogfox’ > file git add -A; git … Read more

Exclude file from “git diff”

Omg, drivers and awk to exclude a lousy file? Since Git 1.9 something you can: git diff — . ‘:(exclude)db/irrelevant.php’ ‘:(exclude)db/irrelevant2.php’ (On Windows, replace the single quotes ‘ by double quotes “.) Ah, elegance! See the quoted answer and for details this answer by @torek.

Filtering a diff with a regular expression

$ git diff –help -G<regex> Look for differences whose added or removed line matches the given <regex>. EDIT: After some tests I’ve got something like git diff -b -w –word-diff-regex=’.*\[[^”]*\]’ Then I’ve got output like: diff –git a/test.php b/test.php index 62a2de0..b76891f 100644 — a/test.php +++ b/test.php @@ -1,3 +1,5 @@ <?php {+$my_array[my_key]+} = “test”; ?> … Read more