How to make ‘git diff’ ignore comments

Here is a solution that is working well for me. I’ve written up the solution and some additional missing documentation on the git (log|diff) -G<regex> option. It is basically using the same solution as in previous answers, but specifically for comments that start with a * or a #, and sometimes a space before the … 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.

List of files changed between commits with JGit

You can use the DiffFormatter to get a list of DiffEntrys. Each entry has a changeType that specifies whether a file was added, removed or changed. An Entrys’ getOldPath() and getNewPath() methods return the path name. The JavaDoc lists what each method retuns for a given change type. ObjectReader reader = git.getRepository().newObjectReader(); CanonicalTreeParser oldTreeIter = … Read more

Ignore *all* whitespace changes with git-diff between commits

Perhaps there is a better answer, but the best solution I’ve found so far is this. First, you must control the definition of “whitespace” that Git is currently using. git config core.whitespace ‘-trailing-space,-indent-with-non-tab,-tab-in-indent’ Next, you must control the definition of a word used. Instead of just using git diff -w, add –word-diff-regex='[^[:space:]]’: git diff -w … Read more