Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List all changed files with change status between Git commits (added, modified, deleted) [duplicate]

Tags:

git

git-diff

I regularly use the following command to list files changed between two commits:

git diff --name-only SHA1 SHA2 

It gives a list of files somewhat like this:

 /src/example/file1 /src/example/file2 /src/example/file3 

There is almost no end to how useful this is.

I'd really like to be able also to show alongside each file a brief reference to the change status, indicating whether a file was added, modified or deleted.

Here's an example to demonstrate the concept:

git diff --name-only --and-how-me-the-change-status SHA1 SHA2 
 A /src/example/file1 M /src/example/file2 D /src/example/file3 

The change status (A, M, D) is shown as an example only, I don't mind what this is so long as it is unambiguous.

I'm aware that I can use the --diff-filter option to list only added files, or only modified files or only deleted files. Using this option means I have to run three commands to get three lists of filenames. This is nice but could be nicer.

Is there a single command I can run to give me the above example output?

like image 975
Jon Cram Avatar asked Mar 07 '13 12:03

Jon Cram


People also ask

How do you see what files were changed in git?

To find out which files changed in a given commit, use the git log --raw command. It's the fastest and simplest way to get insight into which files a commit affects.

How do you display a list of files added or modified in a specific commit?

OK, there are a couple of ways to show all files in a particular commit... To reduce the information and show only names of the files which committed, you simply can add --name-only or --name-status flag... These flags just show you the file names which are different from previous commits as you want...

Which command shows the changes between commits?

"git diff" always show the difference between two commits (or commit and working directory, etc.).


1 Answers

Use --name-status, it's the same as --name-only plus the status of changed files:

git diff --name-status SHA1 SHA2 
like image 50
Alexander Konstantinov Avatar answered Sep 28 '22 16:09

Alexander Konstantinov