git: list all files added/modified on a day (or week/month...)
Asked Answered
E

7

67

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?

Epitome answered 4/11, 2011 at 22:53 Comment(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...Epitome
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.Sporadic
S
58

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
Sporadic answered 4/11, 2011 at 23:19 Comment(7)
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).Borax
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?Sporadic
Yeah, reflog :) (argh, why can't you edit comments past 5 min...)Borax
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....Borax
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.Sporadic
Looks like this only consider changes from reflog, not log.Samanthasamanthia
Really good answer, anyway I'm not able to find the reference in the official git documentation!Intermit
P
52

Maybe this:

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

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

Perm answered 4/11, 2011 at 23:1 Comment(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).Sporadic
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.Bash
L
41

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
Langsyne answered 22/5, 2014 at 10:53 Comment(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.Bedplate
I posted an answer here: #31444227 which deals with the opposite of what this post has requested but it's useful.Bedplate
git whatchanged is deprecated and git log is encouraged in the current version of Git. git-scm.com/docs/git-whatchanged/2.21.0Aniseed
D
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
Downstairs answered 5/11, 2011 at 16:35 Comment(1)
git whatchanged is deprecated and git log is encouraged in the current version of Git. git-scm.com/docs/git-whatchanged/2.21.0Aniseed
G
10

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
Gerrygerrymander answered 17/11, 2015 at 9:42 Comment(0)
C
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.

Crosspollination answered 4/11, 2011 at 23:0 Comment(0)
F
0

Git BASH Command

git whatchanged --since '11/24/2017' --until '11/29/2017' --oneline --name-only --pretty=format: | sort | uniq >> changedlist.txt
Forsberg answered 24/7, 2019 at 9:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.