0

Suppose I touch file,then git add -A,git commit -a several times.
Then I have commits like:

b6913186abd9259f8e3e18f778cbb0743e431a98 commit3
a3309719f0fcee236b794fcb053ee252c762bbac commit2
4fe5675b900d7e20ec94784ad1fb5580581564ce commit1

When I want to know which files added from commit1 to commit3,how to do it?

kittygirl
  • 2,255
  • 5
  • 24
  • 52
  • Does this answer your question? [How to see the changes between two commits without commits in-between?](https://stackoverflow.com/questions/1191282/how-to-see-the-changes-between-two-commits-without-commits-in-between) – OSH Apr 14 '20 at 18:53
  • Does this answer your question? [How to have git log show filenames like svn log -v](https://stackoverflow.com/questions/1230084/how-to-have-git-log-show-filenames-like-svn-log-v) – EncryptedWatermelon Apr 14 '20 at 19:02
  • @OSH,@EncryptedWatermelon,No! changed file may means deleted files.I am looking for the new added file. – kittygirl Apr 14 '20 at 19:10

1 Answers1

-1

You can find the files added between your commit1 and commit3 with

 git diff b69131..4fe567 --name-status | grep ^A

The --name-status parameter will print all the files changed between the two commits, with every file changed in a new line which starts with a certain character. If this caracter is A means the file was added, D for deleted file, M for modified, R for renamed... so we can use grep to filter it.

You can find in the git-diff docs all the options you could use to filter.


Update: look at the comment below by @jthill, it's better for the clean usage of --name-only and --diff-filter.

stjernaluiht
  • 730
  • 6
  • 14