bash : make gr accept head count.

This commit is contained in:
Dmitry Voronin 2023-09-30 07:20:31 +03:00
parent f5f5d08ec4
commit 512732fcb3

View file

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