Skip to content

Instantly share code, notes, and snippets.

@hmsk
Last active November 27, 2017 21:53
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 hmsk/f37fe69842216e0fc866e6cfe61dd925 to your computer and use it in GitHub Desktop.
Save hmsk/f37fe69842216e0fc866e6cfe61dd925 to your computer and use it in GitHub Desktop.
[Run interactive editor for all commits after folking current branch] #git #zsh
#!/bin/sh
_git_rebase_on_current_branch()
{
# https://gist.github.com/joechrysler/6073741
branch=`git rev-parse --abbrev-ref HEAD`
parent_branch=`git show-branch -a 2>/dev/null | grep '\*' | grep -v "$branch" | head -n1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//'`
latest_parent_commit=`git merge-base $parent_branch HEAD`
echo Run rebase interactive editor for commits after $latest_parent_commit
git rebase -i $latest_parent_commit
}
_git_rebase_on_current_branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment