How to find the first commit date of files in git

Will there be a way to see the date of the first commit of a list of files so that I can order them from this list?

In context, I play with Node.JS, using it to create a simple blog where the β€œdatabase” is actually a git repository.

What I thought I would try is to list all the files in a specific directory, and then call something like this:

git log --format="format:%ci" --reverse [my file here] 

This will result in the following:

 2010-09-01 11:42:56 -0700 2010-09-22 12:17:19 -0700 2010-09-22 13:18:11 -0700 2011-03-05 00:11:19 -0800 2011-08-26 08:50:02 -0700 2011-08-26 08:51:50 -0700 

Then take the first result and use it to organize.

Is there a better way?

+4
source share
1 answer

I think you can get what you want using the --diff-filter option for git log by selecting only the added files. For example, you can analyze the output:

 git log --format="format:%ci" --name-only --diff-filter=A 

See the documentation for git log for a more detailed description of the various states understood by --diff-filter .

+6
source

All Articles