I want to see the date of git creation (date of first commit where they were added) of all the files on a specified directory.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’ll break my solution into steps.
Get a list of all files in the repository
This returns a list of relative paths of all files in the repository.
Get the SHA-1 of the first commit of a given file:
This will return a list of all parentless commits for a given file, in reverse chronological order. The last one is the SHA-1 hash of the first commit for the given file.
You can verify this by running
git log --raw <hash>. You should see something like:Show the date of a given commit
Bringing it all together in a bash script: