Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find which files have not changed since commit?

Tags:

git

In git, how can one find out which files in directory have NOT changed since some commit?

like image 307
santervo Avatar asked Jul 21 '14 13:07

santervo


People also ask

How can I tell which files were changed in a commit?

To find out which files changed in a given commit, use the git log --raw command.

How can I see changes not staged for commit?

You can run the git diff HEAD command to compare the both staged and unstaged changes with your last commit.


2 Answers

IMO a far easier way to generate your list would be the following command chain:

git ls-files --full-name | grep -v "$(git diff --name-only <REF>)"

Where <REF> is the hash of the commit from which you want the unchanged files since.


git ls-files list, as you could expect, all versioned files and then you grep all files which aren't in the list of changed files since the specified commit.

like image 154
Sascha Wolf Avatar answered Nov 14 '22 20:11

Sascha Wolf


Use git diff --name-only $REV to get the list of files that have changed. Use git -C $(git rev-parse --show-toplevel) ls-tree -r HEAD --name-only to get the list of all files. Use grep to separate the sets:

git diff ${REV?must specify a REV} --name-only > /tmp/list
git -C $(git rev-parse --show-toplevel) ls-tree -r HEAD  --name-only |
     grep -f /tmp/list -v

Prior to executing those commands, you'll need to specify a rev in the variable REV. eg, REV=HEAD~6 or REV=branch-name~~

like image 32
William Pursell Avatar answered Nov 14 '22 21:11

William Pursell