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?
Asked
Active
Viewed 3.8k times
62
-
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 05 '11 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 05 '11 at 20:37
7 Answers
55
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

inger
- 19,574
- 9
- 49
- 54
-
2Note 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). – snogglethorpe Nov 05 '11 at 09:00
-
1You 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 05 '11 at 11:15
-
Yeah, reflog :) (argh, why can't you edit comments past 5 min...) – snogglethorpe Nov 05 '11 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.... – snogglethorpe Nov 05 '11 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 05 '11 at 13:33
-
-
Really good answer, anyway I'm not able to find the reference in the official git documentation! – Giovanni Patruno Sep 16 '20 at 10:10
49
Maybe this:
git log --since="1 day ago" --name-only --pretty=format: | sort | uniq
Include --until
if you want for a day, week etc.

manojlds
- 290,304
- 63
- 469
- 417
-
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 05 '11 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 '15 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

anshuman
- 3,496
- 1
- 19
- 13
-
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 '15 at 04:27
-
I posted an answer here: http://stackoverflow.com/questions/31443727/git-how-to-list-all-files-that-have-not-been-changed-since-a-certain-date which deals with the opposite of what this post has requested but it's useful. – AKS Jul 16 '15 at 05:44
-
1`git whatchanged` is deprecated and `git log` is encouraged in the current version of Git. https://git-scm.com/docs/git-whatchanged/2.21.0 – Devy May 21 '19 at 17:51
12
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

Go Dan
- 15,194
- 6
- 41
- 65
-
1`git whatchanged` is deprecated and `git log` is encouraged in the current version of Git. https://git-scm.com/docs/git-whatchanged/2.21.0 – Devy May 21 '19 at 17:51
8
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

metal4people
- 131
- 2
- 5
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.

yasar
- 13,158
- 28
- 95
- 160
0
Git BASH Command
git whatchanged --since '11/24/2017' --until '11/29/2017' --oneline --name-only --pretty=format: | sort | uniq >> changedlist.txt

jxramos
- 7,356
- 6
- 57
- 105

Tamilselvan K
- 1,133
- 11
- 10