Skip to content

Instantly share code, notes, and snippets.

@mgoodness
Last active January 5, 2019 00:11
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 mgoodness/3f99876a9422525b23725061ba83c517 to your computer and use it in GitHub Desktop.
Save mgoodness/3f99876a9422525b23725061ba83c517 to your computer and use it in GitHub Desktop.
git-rebase-preserve-author() {
git rebase --preserve-merges $1
root_dir=(git rev-parse --show-toplevel)
while [[ -f ${root_dir}/.git/rebase-merge/stopped-sha ]]; do
stopped_sha=(cat ${root_dir}/.git/rebase-merge/stopped-sha)
git_author_string=(git show -s --format='%an <%ae>' ${stopped_sha})
for c in (git diff --name-only --diff-filter=U); do
eval ${EDITOR} ${root_dir}/$c
done
git commit --all--author=${git_author_string}
git rebase --continue
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment