6

How can I list the files that were newly added in commits between two dates (or between two commits)? I'd like to see

  1. The file path
  2. The committer/commit message
  3. The commit ref
Synesso
  • 37,610
  • 35
  • 136
  • 207

3 Answers3

8

this is what I use:

git log --diff-filter=A --name-only --pretty=oneline --abbrev-commit ref1..ref2

Moreover, the output is quite easy to parse. Removing --abbrev-commit allows you to use the SHA-1 for some job.

Gra
  • 1,542
  • 14
  • 28
  • 2
    Thanks, this is very handy. You can shorten it a smidge by using --oneline, which is --pretty=oneline --abbrev-commit. – rosuav Oct 31 '16 at 02:12
6

git log --stat gives a nice summary of commits with details of files changed:

commit bde0ce475144ec85a1cb4ffeba04815412a07119
Author: Stephen Holdaway <xxxxx@xxxxx.com>
Date:   Thu Sep 20 13:55:12 2012 +1200

    fix default rotation issue

 Menus/MainMenuViewController.m   |   17 +++++++++++++----
 Menus/PostGameViewController.m   |   14 +++++++++++++-
 Menus/StatsMenuController.m      |   10 +++++-----
 4 files changed, 31 insertions(+), 11 deletions(-)

You could try this for between two dates:

git log --since "10 Sep 2012" --until "12 Nov 2012" --stat

And this for between two commits:

git log --stat xxxxxxx..xxxxxxx
Stecman
  • 2,890
  • 20
  • 18
  • Awesome! Do you know how I can see the full path of each file? – Synesso Nov 13 '12 at 23:39
  • You can use `--stat-name-width=1000 --stat-width=1000` to prevent the shortening of paths. You could also add `--name-only` to make the output cleaner. See [Making git diff --stat show full file path](http://stackoverflow.com/questions/10459374/making-git-diff-stat-show-full-file-path) for more detail. – Stecman Nov 13 '12 at 23:50
  • In addition, if you just want to show newly added files, you can use `--diff-filter=A`, though the output is not particularly clear unless you add `--name-status` (in which case the output is identical to the answer @atkretsch posted) – Stecman Nov 14 '12 at 00:19
4

You can also use git show. It's similar to git log but has a --name-status parameter that gives you both the path name and the added/modified/deleted flag in one shot (note that git log as described in the first answer isn't restricted to new files and doesn't display a status indicator).

$ git show --pretty=fuller --name-status HEAD^..HEAD
commit 3c92149119e69b4520b4ea317f221aade9f41b0e
Author: John Doe <xxxx@xxxxxx>
AuthorDate: Fri Nov 9 15:46:05 2012 -0600
Commit: John Doe <xxxx@xxxxxx>
CommitDate: Fri Nov 9 15:46:05 2012 -0600

Added some files, modified some other files

A       src/main/java/com/test/app/NewFile1.java
A       src/main/java/com/test/app/NewFile2.java
M       src/main/java/com/test/app/OldFile1.java
M       src/main/java/com/test/app/OldFile2.java

Might be possible to get this info with git log (they're probably using the same basic info under the hood) but I haven't figured it out.

atkretsch
  • 2,367
  • 18
  • 24