Created
December 6, 2022 10:49
-
-
Save kostaspt/1874b979d0a8d56aaa48e1ba3d61abdb to your computer and use it in GitHub Desktop.
Git Rebase (alias)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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