Arek' Fu
Arek' Fu

Reputation: 857

List of files that were NOT changed by a git commit

I know that

git ls-tree -r --name-only --full-tree <sha1>

will give me the list of all files included in a given commit, while something like

git show --stat --name-only --pretty=format:'' <sha1>

will only list the files that were changed by commit <sha1>.

How do I get a list of the files that were NOT changed by a given git commit? I'm sure it can be done with the commands above plus some sort and diff, but I would rather do it with git if possible.

Upvotes: 0

Views: 221

Answers (1)

twalberg
twalberg

Reputation: 62369

Not sure you can do it purely with git, at least not with just porcelain commands. I would do this:

git ls-tree -r --name-only --full-tree <sha1> | sort > /tmp/allfiles
git show --stat --name-only --pretty=format:'' <sha1> | sort > /tmp/changedfiles
comm -23 /tmp/allfiles /tmp/changedfiles

Upvotes: 2

Related Questions