content

I'm trying to remember again how to print out the time a file was first added to a git repository, so I can add created dates to files that are missing created dates. I know I've searched for this before, and I find this stack overflow answer again.

git log --follow --format=%ad --date default <FILE> | tail -1

With this command you can out all date about this file and extract the last

The option %ad shows the date in the format specified by the --date setting, one of relative, local, iso, iso-strict, rfc, short, raw, human, unix, format:<strftime-string>, default.

Using it, I construct the following command:

git log --follow --format=%ad --date format:%Y-%m-%dT%H:%M:%S%z "content/albums/index.md" | tail -1

This gives me the full ISO 8601 timestamp format with the date, time, and timezone offset. However, I notice after testing this that it's the same as the iso-strict setting.

meta

created:

backlinks: Get the timestamp a file was first added to a git repository

commit: 2669ba0a