Export only modified and added files with folder structure in Git

git diff-tree -r –no-commit-id –name-only –diff-filter=ACMRT $commit_id git diff-tree -r $commit_id: Take a diff of the given commit to its parent(s) (including all subdirectories, not just the top directory). –no-commit-id –name-only: Do not output the commit SHA1. Output only the names of the affected files instead of a full diff. –diff-filter=ACMRT: Only show files added, … Read more

How do I see the differences between two branches?

Use git diff. git diff [<options>] <commit>..​<commit> [–] [<path>…​] <commit> is a branch name, a commit hash, or a shorthand symbolic reference. Examples: git diff abc123..def567, git diff HEAD..origin/master. That will produce the diff between the tips of the two branches. If you’d prefer to find the diff from their common ancestor to test, you … Read more

‘git diff’ doesn’t show enough

The important thing to realize about git diff A B is that it only ever shows you the difference between the states of the tree between exactly two points in the commit graph – it doesn’t care about the history. The .. and … notations used for git diff have the following meanings: So when … Read more

git diff – show me line ending changes?

First, make sure you’re using the coloured output (e.g. with git diff –color) and that you’ve enabled whitespace highlighting with (e.g.) git config color.diff.whitespace “red reverse” This might not work in all cases, however, as git doesn’t appear to highlight trailing whitespace for removed lines. To see whitespace that you’ve deleted, simply use git diff … Read more

git-diff to ignore ^M

GitHub suggests that you should make sure to only use \n as a newline character in git-handled repos. There’s an option to auto-convert: $ git config –global core.autocrlf true Of course, this is said to convert crlf to lf, while you want to convert cr to lf. I hope this still works … And then … Read more

How to read the output from git diff?

Lets take a look at example advanced diff from git history (in commit 1088261f in git.git repository): diff –git a/builtin-http-fetch.c b/http-fetch.c similarity index 95% rename from builtin-http-fetch.c rename to http-fetch.c index f3e63d7..e8f44ba 100644 — a/builtin-http-fetch.c +++ b/http-fetch.c @@ -1,8 +1,9 @@ #include “cache.h” #include “walker.h” -int cmd_http_fetch(int argc, const char **argv, const char *prefix) +int … Read more