Created
September 21, 2017 14:22
-
-
Save obuchtala/5b37101632c9d3883d366be344dd4dc4 to your computer and use it in GitHub Desktop.
Rebasing a branch and retain the original committer information.
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
| #!/usr/bin/env bash | |
| # Fix branch commit data to be the same as author data | |
| set -o errexit -o pipefail -o noglob -o noclobber -o nounset | |
| IFS=$'\n\t' | |
| parent=$1 | |
| # The command to execute for each commit | |
| read -r -d '' command <<-'COMMAND' || true | |
| export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME" | |
| export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL" | |
| export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" | |
| COMMAND | |
| # Rebase the current branch on top of the parent | |
| git rebase -- "$parent" | |
| # Rewrite all commits to use the author data | |
| git filter-branch --force --env-filter "$command" -- "$parent..HEAD" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment