3 ms·
The commit hashes will be different, but I always start a fresh repo with `git commit --allow-empty -m "initial commit"`
by andreareina 6y ago
The commit hashes will be different, but I always start a fresh repo with `git commit --allow-empty -m "initial commit"`
- patrec 6y agoWhy not got the whole mile, and do something like this: GIT_AUTHOR_NAME='nil' GIT_AUTHOR_EMAIL='nil@example.com' \ GIT_COMMITTER_NAME='nil' GIT_COMMITTER_EMAIL='nil@example.com' \ GIT_AUTHOR_DATE='1970-01-01 00:00:01' GIT_COMMITTER_DATE='1970-01-01 00:00:01' \ git commit --no-gpg-sign --allow-empty -m 'NIL' This will give you an identical commit hash every time. [Edit: added --no-gpg-sign as suggested in reply below]
- deleted 6y ago[deleted]
- JNRowe 6y agoYou can ensure the hashes are consistent by setting GIT_AUTHOR_DATE and GIT_COMMITTER_DATE in your initial commit alias. They still won't be consistent if you've enabled commit.gpgSign though. So, you'd want --no-gpg-sign on that initial commit or someone to reply with a better idea.
- patrec 6y agoThanks, incorporated your --no-gpg-sign suggestion. I think it's best to use a canonical author/committer as well. Ideally everyone would agree on something so tooling like commit linters (which check org email addresses or commit message formatting) can ignore it and different repos across at least a single org benefit from having the same root commit.
- JNRowe 6y agoThe other benefit to your full solution is that you won't get a 50 year sidebar in your GitHub contribution profile too. Until seeing your suggestion it hadn't occurred to me to use a fake user. However, using UNIX epoch was something I had been doing and I do have the 50 year sidebar ;) https://github.com/JNRowe#year-list-container https://github.com/JNRowe#year-list-container