eonil
eonil

Reputation: 85975

How to get the date of Git repository init?

Can I get the date/time of git init?

Not the first commit.

If possible, how can I get it?


I am looking for this mainly for revision number in continuous integration. I like to use Git commit hash for version key, but it's an iOS app, and there's some limitation that I have to use only numbers and commas in version string.

Next, I tried to use Unix timestamp (seconds) as a revision number, but it's too large to show some meaningful information for my project. And then, I got another idea that counting seconds since the current Git repository created.

My current idea is,

HEAD_TIMESTAMP=`git show -s --format=%ct HEAD`
INIT_TIMESTAMP=<get init date>
DELTA=`expr $HEAD_TIMESTAMP - $INIT_TIMESTAMP `
DAYS=`expr $DELTA / 86400`
SECS=`expr $DELTA % 86400`
REV=$DAYS.$SECS

I think it's also possible to use date/time of first commit. But I like to use date/time of git init if it's possible because it's the true creation time of the repository.

Upvotes: 2

Views: 2397

Answers (1)

user4329102
user4329102

Reputation:

You can find creation date of .git directory:
stat -c %i .git will give you some number
than run sudo debugfs -R 'stat <your_number>' /dev/sdXY and look at crtime:

Upvotes: 1

Related Questions