Skip to content

Instantly share code, notes, and snippets.

@mgoodness
Created September 4, 2017 23:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgoodness/c252af3c70b307fc6af0ed9e19fce64c to your computer and use it in GitHub Desktop.
Save mgoodness/c252af3c70b307fc6af0ed9e19fce64c to your computer and use it in GitHub Desktop.
function git-rebase-preserve-author -d 'Rebase preserving original author' -a branch
git rebase --preserve-merges $branch
set -l root_dir (git rev-parse --show-toplevel)
while test -f $root_dir/.git/rebase-merge/stopped-sha
set -l stopped_sha (cat $root_dir/.git/rebase-merge/stopped-sha)
set -l git_author_string (git show -s --format='%an <%ae>' $stopped_sha)
for c in (git diff --name-only --diff-filter=U)
eval $EDITOR $root_dir/$c
end
git commit --all --gpg-sign --verbose --author=$git_author_string
git rebase --continue
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment