65

Given a period of time (e.g. a day, a week, a month), is it possible to list all files that were modified or added in this time?

2
  • Thanks, everyone for the many different solutions! I would like to accept all of them since all solve my question. I accept @inger's solution because I like having the modified/added indicator...
    – thias
    Nov 5, 2011 at 18:45
  • Actually --name-status works with git log as well. Also please not the comments of my answer, which point out a limitation..will clarify soon.
    – inger
    Nov 5, 2011 at 20:37

7 Answers 7

56

I'd use diff to yield the file list directly, e.g:

git diff --name-only "@{3 days ago}" "@{2 days ago}"

changelog.txt
newfile.txt

In case you're curious which file got modified or added, use --name-status instead:

git diff --name-status "@{3 days ago}" "@{2 days ago}"

M       changelog.txt
A       newfile.txt
7
  • 2
    Note that the @{...} notation can be unreliable—it might have a much coarser granularity than the actual commits—because it uses rev-log entries to map dates to commits, and entries are only added to the rev-log for your actions(and not, for instance, for every commit in a pull). Nov 5, 2011 at 9:00
  • 1
    You mean reflog? Anyway, thanks for the reminder - I'd have used --since and --until but that doesn't seem to give the expected results. Do you know a more reliable alternative?
    – inger
    Nov 5, 2011 at 11:15
  • Yeah, reflog :) (argh, why can't you edit comments past 5 min...) Nov 5, 2011 at 12:13
  • BTW, not sure why you've had issues with --since and --until (I presume you mean with git log)—I've used them a fair bit, and they seem to always give the expected results, with commit granularity (even in cases where @{...} doesn't). @manojlds' answer looks pretty good to me.... Nov 5, 2011 at 12:20
  • No I used --since/--until with git diff - which seem to work even though it doesn't seem to be advertised on the man pages. I prefer diff for this use case: it's more direct; I use it all the time the same purposes, just not typically with dates. I kind of think both should yield the same, I will check if there is a known issue here with the git log pipeline as a workaround.
    – inger
    Nov 5, 2011 at 13:33
50

Maybe this:

  git log --since="1 day ago" --name-only --pretty=format: | sort | uniq

Include --until if you want for a day, week etc.

2
  • You can spare one command using -u: git log --since="1 day ago" --name-only --pretty=format: | sort -u .. Even thought this still more complicated than a simple git diff .. which OTOH, may have an issue with current git (see my answer's comments).
    – inger
    Nov 5, 2011 at 20:34
  • Not sure about using uniq in this solution. There might be different commits with same number of files changed, insertions and deletions, which will vanish if you pipe the result through uniq.
    – i4h
    Oct 19, 2015 at 13:52
40

I use this to get a clean list:

git whatchanged --since '04/14/2013' --until '05/22/2014' --oneline --name-only --pretty=format: | sort | uniq >> changedlist.txt
3
  • How to run similar command to see what files have not changed since 04/14/15 until 05/22/2014 or within last 7 days / week? Thx.
    – AKS
    Jul 16, 2015 at 4:27
  • I posted an answer here: stackoverflow.com/questions/31443727/… which deals with the opposite of what this post has requested but it's useful.
    – AKS
    Jul 16, 2015 at 5:44
  • 2
    git whatchanged is deprecated and git log is encouraged in the current version of Git. git-scm.com/docs/git-whatchanged/2.21.0
    – Devy
    May 21, 2019 at 17:51
11

Git whatchanged should give you what you want, listing what files were modified.

Here's an example using Git source:

$ git --version
git version 1.7.8.rc0.35.gee6df
$ git whatchanged --since '10/27/2011' --until '10/30/2011' --oneline
55e7c0a (squash) test for previous
:100755 100755 dbf623b... 53905a2... M  t/t8006-blame-textconv.sh
2564aa4 blame.c: Properly initialize strbuf after calling, textconv_object()
:100644 100644 173f286... e39d986... M  builtin/blame.c
e8e1c29 Update draft release notes to 1.7.8
:100644 100644 3045245... ddb8d37... M  Documentation/RelNotes/1.7.8.txt
8debf69 clone: Quote user supplied path in a single quote pair
:100644 100644 488f48e... efe8b6c... M  builtin/clone.c
1
9

Here is one more without empty lines:

git log --after="2015-11-05T16:36:00-02:00" --before="2015-11-15T16:36:00-02:00" --pretty=format:"" --name-only | sed '/^\s*$/d' | sort | uniq -u
5

Try:

git log --since="2 days ago" --until="1 days ago"

If you omit --until you will get logs for last two days. You can also spesify weeks, months etc. You can also use git diff with --since and --until parameters. Work a little bit on output formatting and you are done.

0

Git BASH Command

git whatchanged --since '11/24/2017' --until '11/29/2017' --oneline --name-only --pretty=format: | sort | uniq >> changedlist.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.