Skip to content

Instantly share code, notes, and snippets.

@sokil
Last active August 2, 2017 10:53
Show Gist options
  • Save sokil/a00a220a0b66dee0491e9fdf8c935a89 to your computer and use it in GitHub Desktop.
Save sokil/a00a220a0b66dee0491e9fdf8c935a89 to your computer and use it in GitHub Desktop.
Change git commit date
#!/bin/bash
# show commiter date and authot date
git log --format=fuller
# commit 0b4cbb6028d413b582c8710166ff66a3fc56f80e
# Author: Dmytro Sokil <[email protected]>
# AuthorDate: Wed Aug 2 09:19:06 2017 +0300
# Commit: Dmytro Sokil <[email protected]>
# CommitDate: Wed Aug 2 09:19:06 2017 +0300
# show commiter date and authot date of concrete commit
git show 0b4cbb6028d413b582c8710166ff66a3fc56f80e --format=fuller
# commit 0b4cbb6028d413b582c8710166ff66a3fc56f80e
# Author: Dmytro Sokil <[email protected]>
# AuthorDate: Wed Aug 2 09:19:06 2017 +0300
# Commit: Dmytro Sokil <[email protected]>
# CommitDate: Wed Aug 2 09:19:06 2017 +0300
# ignore timezone error
# [fsck]
# badTimezone = ignore
# Ignore specific errors:
# [transfer]
# fsckobjects = true
# [fetch]
# fsckobjects = true
# fsck.badTimezone = ignore
# [receive]
# fsckObjects = true
# Ignore all errors:
# [transfer]
# fsckobjects = false
# [fetch]
# fsckobjects = false
# [receive]
# fsckObjects = false
# change broken commit
git filter-branch --env-filter "if test \$GIT_COMMIT = '0b4cbb6028d413b582c8710166ff66a3fc56f80e'; then export GIT_AUTHOR_DATE; export GIT_COMMITTER_DATE; GIT_AUTHOR_DATE='Tue Jul 8 19:41:47 2014 +0300'; GIT_COMMITTER_DATE='$date'; fi";
rm -fr "$(git rev-parse --git-dir)/refs/original/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment