0

I am trying to change a make file for a different platform in our project, and it would be really handy to be able to see all files added since a certain date. The main problem is that there are a huge number of files, and remembering which files still need to be added can take a lot of tries. Is there a way to query this file list in git or other command line tools?

David
  • 1,648
  • 1
  • 16
  • 31
  • 1
    https://stackoverflow.com/a/50521039/7976758 : `git diff --diff-filter=A --since='the date'` Found in https://stackoverflow.com/search?q=%5Bgit%5D+list+files+since+date – phd Jun 22 '22 at 22:13
  • @phd - I haven't used command line Dif before. This never returns anything for me. Is this only diffing currently staged/unstaged changes, or all commits? – David Jun 23 '22 at 06:30
  • 1
    @phd : `--since` is for `git log`. You would need something like `master@{}` or `$(git rev-list -1 --before="")` for `git diff` – LeGEC Jun 23 '22 at 07:31
  • @David : since you are mentioning `make`, you probably want to compare timestamps of files on disk with timestamps in commits. Is that correct ? – LeGEC Jun 23 '22 at 07:32
  • @LeGEC You're absolutely right! – phd Jun 23 '22 at 08:47

1 Answers1

2

note: I think your question needs more details.

can you explain what you intend to do with that list in your Makefile ?


One way to get that list is to run git diff between the current commit, and a commit reported to be created at that past date.

To get that commit in the past, you can try :

git rev-list -1 --before="<date>"

To use git diff to only list file names of files that were added since that commit :

git diff --no-renames --name-only --diff-filter=A \
     $(git rev-list -1 --before="<date>" HEAD) HEAD
LeGEC
  • 46,477
  • 5
  • 57
  • 104
  • So this looks like it would work great, but under Apple git, many of these command line flags don't seem to exist. What version of git are you using? – David Jun 24 '22 at 19:33
  • afaik "apple git" is regular git. The options above have been there for a long time. What git version are you using ? – LeGEC Jun 25 '22 at 10:37
  • I installed git off of Homebrew so it is working now. I did just find an error in your command. In the git rev-list command , you also need to put HEAD after it for it to work. Other than that, its perfect! Could you edit it and then I'll accept. It should read "git diff --no-renames --name-only --diff-filter=A $(git rev-list -1 --before="" HEAD) HEAD" – David Jun 26 '22 at 20:24