Skip to content

Instantly share code, notes, and snippets.

@mgoodness
Last active January 5, 2019 00:11
Show Gist options
  • Save mgoodness/3f99876a9422525b23725061ba83c517 to your computer and use it in GitHub Desktop.
Save mgoodness/3f99876a9422525b23725061ba83c517 to your computer and use it in GitHub Desktop.

Revisions

  1. mgoodness revised this gist Jan 5, 2019. 1 changed file with 12 additions and 12 deletions.
    24 changes: 12 additions & 12 deletions git-rebase-preserve-author.sh
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,16 @@
    #!/usr/bin/env bash
    git-rebase-preserve-author() {
    git rebase --preserve-merges $1

    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})

    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

    for c in (git diff --name-only --diff-filter=U); do
    eval ${EDITOR} ${root_dir}/$c
    git commit --all--author=${git_author_string}
    git rebase --continue
    done

    git commit --all--author=${git_author_string}
    git rebase --continue
    done
    }
  2. mgoodness revised this gist Jan 4, 2019. 2 changed files with 16 additions and 16 deletions.
    16 changes: 16 additions & 0 deletions git-rebase-preserve-author.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #!/usr/bin/env bash

    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
    16 changes: 0 additions & 16 deletions git-rebase-preserve-author.zsh
    Original file line number Diff line number Diff line change
    @@ -1,16 +0,0 @@
    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
    }
  3. mgoodness created this gist Jan 4, 2019.
    16 changes: 16 additions & 0 deletions git-rebase-preserve-author.zsh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    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
    }