Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get a unique list of files modified in a repository within a range of commits in Git?

Tags:

git

I would like to obtain a list of files from a git repository that have been modified or created within a range of commits. Is this possible? I've taken a look at log but it doesn't seem to achieve this.

like image 897
Sio Avatar asked Jan 22 '12 23:01

Sio


People also ask

How would you display the list of files changed in a particular commit?

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

Which command would you use in order to list files that have any changes when compared to the last commit?

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


1 Answers

git diff --name-only ${range} will give you exactly what you want: only the names of files modified in this time.

Actually, it gives you almost what you asked for: this would include files that were completely deleted, not just modified files. It would also miss files that were created, then removed, within the range.

To get the complete picture you would probably want to walk the range and then uniq the results; use git log to get the range of commits, then diff each against the parent.

like image 168
Daniel Pittman Avatar answered Oct 07 '22 00:10

Daniel Pittman