diff --git a/document/linux/config/bash/module/git.sh b/document/linux/config/bash/module/git.sh index cc294df..42d10ce 100644 --- a/document/linux/config/bash/module/git.sh +++ b/document/linux/config/bash/module/git.sh @@ -7,7 +7,6 @@ alias gst="git stash" alias gd="git diff" alias gc="git commit -m" alias gch="git checkout" -alias gr="git rebase -i" alias gb="git branch" alias gco="git checkout" alias gf="git fetch" @@ -28,3 +27,21 @@ ga() git diff $@ git add $@ } + +# rebase by X commits or from root. +gr() +{ + local base="${1}" + + # rebase last 2 commits by default. + if [[ "${base}" = "" ]]; then + base="2" + fi + + # if 0, rebase from root. else from specified base. + if [[ "${base}" = "0" ]]; then + git rebase -i --root + else + git rebase -i HEAD~${base} + fi +}