Last active
September 21, 2015 22:30
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [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