# Hiding your timezone when using `git`

**URL:** https://discuss.privacyguides.net/t/hiding-your-timezone-when-using-git/40815
**Category:** Questions
**Created:** 2026-09-18T02:27:23Z
**Posts:** 8

## Post 1 by @hashcatHitman — 2026-09-18T02:27:23Z

It hadn’t occurred to me before, but a timezone offset is recorded and published when making commits with `git`. Similar to how browsers like Librewolf will spoof your timezone, I wondered if there was a way to spoof the timezone when using `git`.

I found some discussion on the mailing list archives, but it looks like it went stale. See:

- [(ISSUE) Stop accessing, storing, and sharing the user’s time zone](https://lore.kernel.org/git/CAEOYnAQYMrNAe9s1V-0DVLdL-B_KpHMDP5e=yRnbCkMWdrvFHQ@mail.gmail.com/)

For now, it seems like prefixing commands with any of `TZ=GMT`, `TZ=UTC`, or `TZ=UTC0` will temporarily set your offset to 0.

As far as I can tell, there isn’t really any downside to this other than maybe making `git log` a little confusing? Does anyone know of any particular reason one shouldn’t be doing this? It seems like it might be a nice idea.

---

## Post 2 by @TheManWithNoPlan — 2026-09-18T05:38:54Z

I do this for anything that I use to access the internet on a regular basis, so I’ve modified the files for the launchers of my web browsers as well and added a script to do it at the end of the package manager installing upgrades. As such, it calls a script that chooses a random timezone. I have a few things happening but I’m not sure if the other ones work or not, though the launcher variable call a script that launches things that look like this and common cli tools are an alias for something that does the same:

```
TZ="$(tzchange)" LC_ALL=$(LCchange) LANG=$(LCchange) LANGUAGE=$(LANGUAGEchange)
```

It was a bit of work when I first did it so I won’t explain it other than the subshells output a randomized value, but you can see what’s happening here I think.

Anyway, to answer your question, I personally think it’s a **great** idea to change the timezone like that. I don’t know if the confusion it creates on git makes it undesirable or not but I’d suggest it for things that don’t matter. With the web browsers you can hit different vpn end points really easily, I have a keyboard shortcut to change to a random endpoint, and spoof the timezone, so win win. It takes a little commitment to set it all up is all.

---

## Post 3 by @dngray — 2026-09-18T07:31:30Z

I just set up an alias in git config like:

```
[alias]
	cu = !git commit --date=\"$(date --utc +%Y-%m-%dT%H:%M:%S%z)\"
```

`git cu` then always is commit utc You can then do things like:

```
[includeIf "gitdir:**/dngray/*/"]
  path = ~/.config/git/users/dngray
```

For specific settings based on the location they’re in. I tend to store all my source code in ~/src/`<forge>`/`<user or org>`/`<repo>`.

In that file I have the standard things, like `[user]`, `[commit]`, `[sendemail]`, and `[core] sshCommand`. The advantage of doing this is you can specify a [specific SSH command](https://github.com/dngray/dotfiles/blob/2dbab749e34f1b8e98da9d1542db7ebeb55a5ccf/home/.chezmoitemplates/git/user) and not have these littering up your ~/.ssh/config.

---

## Post 4 by @hashcatHitman — 2026-09-18T13:51:12Z

> [@dngray](#):
>
> I just set up an alias in git config like:
> 
> ```
> [alias]
> cu = !git commit --date=\"$(date --utc +%Y-%m-%dT%H:%M:%S%z)\"
> ```
> 
> `git cu` then always is commit utc

Wouldn’t an alias like this only work for direct commits/amending? I think you’d still end up publishing your actual timezone when rebasing (and whatever other commands might lead to changing the commit date).

> [@dngray](#):
>
> You can then do things like:
> 
> ```
> [includeIf "gitdir:**/dngray/*/"]
> path = ~/.config/git/users/dngray
> ```
> 
> For specific settings based on the location they’re in. I tend to store all my source code in ~/src/`<forge>`/`<user or org>`/`<repo>`.
> 
> In that file I have the standard things, like `[user]`, `[commit]`, `[sendemail]`, and `[core] sshCommand`. The advantage of doing this is you can specify a [specific SSH command](https://github.com/dngray/dotfiles/blob/2dbab749e34f1b8e98da9d1542db7ebeb55a5ccf/home/.chezmoitemplates/git/user) and not have these littering up your ~/.ssh/config.

Ah, yes, `includeIf` is quite nice. I’m already using it, but I do mine (mostly) based on remote URLs since I am not worried about littering my `~/.ssh/config` at the moment (the exception being that I use a [directory-based `includeIf` to allow `cargo-audit` to use HTTPS to update the advisory database](https://github.com/hashcatHitman/dotfiles/blob/76654dd6c20dba5bb0a58b66ce86b81b29b2880b/.gitconfig#L111-L113), since [it does not support SSH](https://github.com/rustsec/rustsec/issues/1248)).

---

## Post 5 by @hashcatHitman — 2026-09-18T19:18:10Z

> [@dngray](#):
>
> I just set up an alias in git config like:
> 
> ```
> [alias]
> cu = !git commit --date=\"$(date --utc +%Y-%m-%dT%H:%M:%S%z)\"
> ```
> 
> `git cu` then always is commit utc

Actually, it’s worse than I originally said. I just tried this alias, and it doesn’t even correctly protect `git commit`. Using the `git cu` alias as defined will set the author date to UTC, but the commit date will still be in your system timezone (you can verify using `git show -p HEAD --format=raw` after using `git cu`). You can fix this by adding the `TZ` environment variable to the command like so:

```
[alias]
cu = !TZ=UTC0 git commit --date=\"$(date --utc +%Y-%m-%dT%H:%M:%S%z)\"
```

Or by adding the `GIT_COMMITTER_DATE` environment variable to the command like so:

```
[alias]
cu = !GIT_COMMITTER_DATE=\"$(date --utc +%Y-%m-%dT%H:%M:%S%z)\" git commit --date=\"$(date --utc +%Y-%m-%dT%H:%M:%S%z)\"
```

Though, at that point, since you’re adding an environment variable anyway, it’s probably easier to just do:

```
[alias]
cu = !TZ=UTC0 git commit
```

---

## Post 6 by @hashcatHitman — 2026-09-22T22:21:46Z

So I’ve confirmed the existence of at least three different dates in Git that you could leak your timezone through.

Commits have an author date and a commit date. I knew this for a while; I think most people using git do?

The third date is the tagger date, present on annotated tags. This information can be kind of hard to get at. You can’t make it show up in `git log`, and for _some reason_ it is also missing from `git show --format=raw <tag>`. The ways I’ve found to access it are:

```
# Specific tag
git show --format=fuller <tag>
git cat-file tag <tag>
git for-each-ref --format='taggerdate: %(taggerdate)' refs/tags/<tag>
git tag --format='taggerdate: %(taggerdate)' --list <tag>

# All tags
git for-each-ref --format='taggerdate: %(taggerdate)' refs/tags
git tag --format='taggerdate: %(taggerdate)' --list
```

There are also these things called “merge tags”, which happen when an annotated tag is merged into the current branch. I haven’t figured out how to change them. They copy the taggerdate from the annotated tag. If you do `git show --format=raw --no-patch <merge_commit_hash>` you should be able to see it in there. Merge tags won’t happen if the person merging sets `merge.ff=only` in `.gitconfig`.

For author date and commit date, I’ve found it reliable to alias `git` in `.bashrc` like so:

```
# Set the timezone offset to +0000 for git commands.
alias git='TZ=UTC0 git'
```

This is preferable to the earlier `git cu` alias, as that was specific to commits and wouldn’t apply to tags, rebasing, merging, etc.

If you want to bulk set the timezone in a repository, I’ve made this alias in `.gitconfig`:

```
# If you alias `git='TZ=UTC0 git'` in `.bashrc`, for example, this will set
# the timezone of every author date and commit date of every commit to UTC0,
# without changing the timestamp. That is, a commit authored 1 week ago and
# committed 2 hours ago will still show as authored 1 week ago and committed
# 2 hours ago.
tz-reset = "-c rebase.instructionFormat='%s%nexec GIT_COMMITTER_DATE=\"@%ct\" git commit --amend --no-edit --date=\"@%at\"' rebase -i"
```

You would do `git tz-reset --root` to do every single commit on the currently checked out branch. This is rewriting history, of course, so you can’t just go and do this on every repository you’ve contributed to, and you should be aware of the consequences of rewriting history.

This will not update tags. I think for tags you’d have to delete them and recreate them, which isn’t always viable. People who already have the old tag won’t automatically get the new one when they `git pull`, so I think you mostly have to give up for published tags.

---

## Post 7 by @dngray — 2026-09-22T23:28:36Z

This was quite informative.

> [@hashcatHitman](#):
>
> For author date and commit date, I’ve found it reliable to alias `git` in `.bashrc` like so:
> 
> ```
> # Set the timezone offset to +0000 for git commands.
> alias git='TZ=UTC0 git'
> ```

It would seem that way. I forget why I didn’t do that originally. For fish shell you’ll need to do:

```
alias git='TZ=UTC0 command git'
```

---

## Post 8 by @hashcatHitman — 2026-09-27T15:03:47Z

Well, a few more notes on this, for the benefit of the readers.

I learned something new about… Bash? POSIX? Linux? Maybe it’s a stretch to say I learned anything if I don’t know what I learned it about. But, anyway, point is that if you use `git` inside a script, such as in this excerpt from [`force_push_comparison.bash`](https://github.com/hashcatHitman/dotfiles/blob/0e291fcacce12dd5865d3e8dd04bc5f1d3a77a9a/home/bin/force_push_comparison.bash):

```
#!/bin/bash

# SPDX-FileCopyrightText: © 2026 hashcatHitman
#
# SPDX-License-Identifier: Apache-2.0 OR MIT

# SNIP! Lines omitted.

alice_commit() {
    local alice_file="${1}"
    local commit_id="${2}"

    echo -e "${ALICE_COLOR}Alice adding commit ${commit_id}...${RESET}"
    cd "${ALICE_CLONE_DIR}" || exit 1
    echo "${alice_file}" >"${alice_file}.txt" || exit 1
    git add "${alice_file}.txt" || exit 1
    git commit -m "commit ${commit_id}: add ${alice_file}.txt" || exit 1
    git push "${REMOTE}" || exit 1
}

# SNIP! Lines omitted.
```

The script does _not_ inherit your aliases from your `.bashrc`. If you want to fix this, at least, in a Bash script (at least, in my case. You should verify on your own system rather than taking what I say as fact), you can either:

Export the `TZ` variable with the preferred timezone:

```
#!/bin/bash

# SPDX-FileCopyrightText: © 2026 hashcatHitman
#
# SPDX-License-Identifier: Apache-2.0 OR MIT

export TZ='Etc/UTC'

# SNIP! Lines omitted.

alice_commit() {
    local alice_file="${1}"
    local commit_id="${2}"

    echo -e "${ALICE_COLOR}Alice adding commit ${commit_id}...${RESET}"
    cd "${ALICE_CLONE_DIR}" || exit 1
    echo "${alice_file}" >"${alice_file}.txt" || exit 1
    git add "${alice_file}.txt" || exit 1
    git commit -m "commit ${commit_id}: add ${alice_file}.txt" || exit 1
    git push "${REMOTE}" || exit 1
}

# SNIP! Lines omitted.
```

or prefix every command with the timezone you like:

```
#!/bin/bash

# SPDX-FileCopyrightText: © 2026 hashcatHitman
#
# SPDX-License-Identifier: Apache-2.0 OR MIT

TZ='Etc/UTC'

# SNIP! Lines omitted.

alice_commit() {
    local alice_file="${1}"
    local commit_id="${2}"

    echo -e "${ALICE_COLOR}Alice adding commit ${commit_id}...${RESET}"
    cd "${ALICE_CLONE_DIR}" || exit 1
    echo "${alice_file}" >"${alice_file}.txt" || exit 1
    # In theory, you only actually need this in front of commands like `git commit`,
    # `git rebase`, `git tag`, `git merge`, and so on. Better safe than sorry, in my
    # opinion.
    TZ="${TZ}" git add "${alice_file}.txt" || exit 1
    TZ="${TZ}" git commit -m "commit ${commit_id}: add ${alice_file}.txt" || exit 1
    TZ="${TZ}" git push "${REMOTE}" || exit 1
}

# SNIP! Lines omitted.
```

Between the two, I think you should prefer the former (exporting, to be clear), because if your script calls another script that also makes commits:

```
#!/bin/bash

# SPDX-FileCopyrightText: © 2026 hashcatHitman
#
# SPDX-License-Identifier: Apache-2.0 OR MIT

# SNIP! Lines omitted.

alice_commit() {
    local alice_file="${1}"
    local commit_id="${2}"

    echo -e "${ALICE_COLOR}Alice adding commit ${commit_id}...${RESET}"
    cd "${ALICE_CLONE_DIR}" || exit 1
    echo "${alice_file}" >"${alice_file}.txt" || exit 1
    # In theory, you only actually need this in front of commands like `git commit`,
    # `git rebase`, `git tag`, `git merge`, and so on. Better safe than sorry, in my
    # opinion.
    git add "${alice_file}.txt" || exit 1
    git commit -m "commit ${commit_id}: add ${alice_file}.txt" || exit 1
    git push "${REMOTE}" || exit 1
}

./script_that_does_some_git_stuff.bash

# SNIP! Lines omitted.
```

It inherits the exported `TZ`.

That all being said, I’ve ultimately decided that the best way to avoid leaking your timezone is to just change the timezone on your entire system. On KDE, you can configure your taskbar clock to show a different timezone anyway (just be careful not to leak it through the configuration files/screenshots if you do). I haven’t figured out how to do that with the lock screen clock. You should probably change your timezone through your GUI settings manager (assuming your DE has one) to make sure it changes any extra things it might need to.

I’ve switched to using `Etc/UTC` for `TZ` related purposes instead of something like `UTC0` because:

- `Etc/UTC` is actually listed by `timedatectl list-timezones`
- On Tails, `/etc/localtime` is a symbolic link to `/usr/share/zoneinfo/Etc/UTC`

So while they should generally be equivalent, `Etc/UTC` feels more “correct” to me.
