Skip to content

Instantly share code, notes, and snippets.

@DannyNemer
Last active September 21, 2015 22:30
Show Gist options
  • Select an option

  • Save DannyNemer/26728469f443d5813dc8 to your computer and use it in GitHub Desktop.

Select an option

Save DannyNemer/26728469f443d5813dc8 to your computer and use it in GitHub Desktop.
A useful git command to restore a repo's commit dates following a rebase
[alias]
# `git restore-dates [$number]` restores the commit dates to corresponding
# author dates of the `$number` most recent commits, or all commits if `$number`
# is undefined. This is useful after a rebase.
restore-dates = !"restoreDates() { \
cd $(git rev-parse --show-toplevel); \
git stash; \
git filter-branch --env-filter \
'GIT_COMMITTER_DATE=$GIT_AUTHOR_DATE; export GIT_COMMITTER_DATE' -f \
$([[ -n "$1" ]] && echo HEAD~$1..HEAD); \
git stash pop; \
}; restoreDates"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment