Last active
October 14, 2024 15:54
-
-
Save dfdemar/d33f9fb4dabe2d9652ef72d2a539e9e7 to your computer and use it in GitHub Desktop.
Sets the committer date to the author date for every commit in a git branch
This file contains 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
#!/bin/bash | |
# Get the current branch name | |
BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
# Get the first commit on the current branch that is not on the main branch | |
FIRST_COMMIT=$(git rev-list main..${BRANCH} --reverse | head -1) | |
# Change the committer date to the author date for all commits from the first commit to the current branch | |
git filter-branch -f --env-filter 'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"' \ | |
--commit-filter 'git commit-tree -S "$@";' ${FIRST_COMMIT}^...${BRANCH} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment