How can I ignore committing timezone information in my commit?

You can use this command to commit in UTC time:

git commit --date="`date --utc +%Y-%m-%dT%H:%M:%S%z`"

You can also alias it to a convenient name:

git config --global alias.commitutc '!git commit --date="$(date --utc +%Y-%m-%dT%H:%M:%S%z)"'

And do git commitutc.

For a more detailed explanation take a look at this blog post.


When committing, git stores the Unix timestamp (seconds since 1/1/1970 UTC), and the local offset of the committer. You can override the offset, but you also have to supply the date as well.

git commit --date 1401179025 -0700

Multiple formats are supported, as documented here. I prefer the ISO-8601 format, which is like this:

git commit --date 2014-05-27T01:23:45-07:00

You can set the offset however you like. Use zero for UTC. Personally, I think this is unnecessary. It actually reduces the amount of information in the log. You may only care about the exact moment in time, but perhaps one might also care what time it was for that particular committer. For example, maybe you'd like to know if that person committed early in the morning or late at night. If you don't store the local offset, then that information is lost, and storing it doesn't hurt.

If your primary concern is that viewing the git log doesn't align all of the commits to a single time zone, consider adjusting the log output using the --date options on the log command:

git log --date=local

The above uses the commit offsets to adjust the commit date to your own local time zone.

I didn't see anything that would adjust it to UTC directly, but you could set your own time zone to UTC and then use this command.

Tags:

Git

Timezone

Date