Introduction
Commit smaller chunks of code often, and always commit in the present.
git-commit man page: https://git-scm.com/docs/git-commit
git commit
takes author and committer information from the following environment variables if they are set:
GIT_AUTHOR_NAME
GIT_AUTHOR_EMAIL
GIT_AUTHOR_DATE
GIT_COMMITTER_NAME
GIT_COMMITTER_EMAIL
GIT_COMMITTER_DATE
While author/committer name and email environment variables are useful for overrides, we are more interested in GIT_AUTHOR_DATE
and GIT_COMMITTER_DATE
.
Date format
ISO 8601 format YYYY-MM-DDTHH:MM:SS +TZOF
with T
replaced with space and +TZOF
representing the timezone of choice (say, +0530 in the case of IST (Indian Standard Time)).
Example: 2013-05-13 09:00:00 +0530
Supported date formats are further explained on git-commit man page {{< newtabref href=””https://git-scm.com/docs/git-commit#_date_formats“” title=””https://git-scm.com/docs/git-commit#_date_formats“” >}}
Commit command
GIT_AUTHOR_DATE=""2020-11-30 00:12:24 +0530"" GIT_COMMITTER_DATE=""2020-11-30 00:12:24 +0530"" git commit -m ""Adding editor config""
# [main 236973a] Adding editor config
# 3 files changed, 94 insertions(+), 2 deletions(-)
# create mode 100644 .editorconfig
Check the outcome via git log
.
git log -1
# commit 236973afc671b6812dd2713deb973f61b0dc0234 (HEAD -> main)
# Author: Pranav Kulkarni [[email protected]](mailto:[email protected])
# Date: Mon Nov 30 00:12:24 2020 +0530
# Adding editorconfig