git: list all files added/modified on a day (or we

2019-02-01 04:39发布

问题:

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?

回答1:

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


回答2:

Maybe this:

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

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



回答3:

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


回答4:

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


回答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.



回答6:

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


标签: git git-log