Skip to content

Instantly share code, notes, and snippets.

@dm
Created August 9, 2017 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dm/aad8e34a5ee6b542a0bc788375b548ed to your computer and use it in GitHub Desktop.
Save dm/aad8e34a5ee6b542a0bc788375b548ed to your computer and use it in GitHub Desktop.
Partial functions.git.zsh
# <snip>
# Destructive! Resets all rebased commit dates to COMMITER_DATE
git-reset-dates() {
echo "Usage: git-reset-dates [ SHA1..HEAD ]"
echo "Are you sure you wish to reset git commit dates to COMMITER_DATE? (y/N)"
read REPLY
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
if [ -z $1 ]; then
git filter-branch --env-filter 'GIT_COMMITTER_DATE=$GIT_AUTHOR_DATE; export GIT_COMMITTER_DATE'
else
git filter-branch --env-filter 'GIT_COMMITTER_DATE=$GIT_AUTHOR_DATE; export GIT_COMMITTER_DATE' $1
fi
fi
}
# Destructive! Resets all rebased commit dates to AUTHOR_DATE
git-reset-dates-original() {
echo "Usage: git-reset-dates [ SHA1..HEAD ]"
echo "Are you sure you wish to reset git commit dates to AUTHOR_DATE? (y/N)"
read REPLY
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
if [ -z $1 ]; then
git filter-branch --env-filter 'GIT_AUTHOR_DATE=$GIT_COMMITTER_DATE; export GIT_AUTHOR_DATE'
else
git filter-branch --env-filter 'GIT_AUTHOR_DATE=$GIT_COMMITTER_DATE; export GIT_AUTHOR_DATE' $1
fi
fi
}
# </snip>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment