Skip to content

Instantly share code, notes, and snippets.

@kostaspt
Created December 6, 2022 10:49
Show Gist options
  • Save kostaspt/1874b979d0a8d56aaa48e1ba3d61abdb to your computer and use it in GitHub Desktop.
Save kostaspt/1874b979d0a8d56aaa48e1ba3d61abdb to your computer and use it in GitHub Desktop.
Git Rebase (alias)
unalias gr
gr() {
if [ -z $1 ]; then branch="master"; else branch=$1; fi
old_stash=$(git rev-parse -q --verify refs/stash)
git stash save -u
git checkout $branch
git pull --rebase
git checkout -
git rebase $branch
new_stash=$(git rev-parse -q --verify refs/stash)
[ "$old_stash" != "$new_stash" ] && git stash pop
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment