2023-08-08 16:24:15 +03:00
|
|
|
# short aliases.
|
|
|
|
alias gps="git push"
|
2023-10-14 02:09:58 +03:00
|
|
|
alias gpsf="git push --force"
|
2023-08-08 16:24:15 +03:00
|
|
|
alias gpl="git pull"
|
|
|
|
alias gl="git log"
|
|
|
|
alias gs="git status"
|
|
|
|
alias gst="git stash"
|
|
|
|
alias gd="git diff"
|
|
|
|
alias gc="git commit -m"
|
|
|
|
alias gch="git checkout"
|
2023-10-26 22:19:01 +03:00
|
|
|
alias gchb="git checkout -b"
|
2023-10-23 04:54:33 +03:00
|
|
|
alias gb="git branch --all"
|
2023-10-26 22:14:47 +03:00
|
|
|
alias gbd="git branch -D"
|
|
|
|
alias gf="git fetch --all -v -p"
|
2023-08-08 16:24:15 +03:00
|
|
|
alias gt="git tag"
|
|
|
|
alias gi="git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached"
|
|
|
|
alias gpc="git diff >"
|
|
|
|
alias gp="git apply"
|
|
|
|
|
|
|
|
# get current git tag.
|
|
|
|
git_tag()
|
|
|
|
{
|
|
|
|
git log | grep commit -m1 | sed -e "s/.*\ //g" | cut -c 1-11;
|
|
|
|
}
|
|
|
|
|
2023-10-30 03:49:10 +03:00
|
|
|
# alias to preview diff while adding. adds current dir by default.
|
|
|
|
# usage: ga [FILES]
|
2023-08-08 16:24:15 +03:00
|
|
|
ga()
|
|
|
|
{
|
2023-10-30 03:49:10 +03:00
|
|
|
local target=${@}
|
|
|
|
|
|
|
|
if [[ "${target}" = "" ]]; then
|
|
|
|
target="."
|
|
|
|
fi
|
|
|
|
|
|
|
|
git diff ${target}
|
|
|
|
git add ${target}
|
2023-08-08 16:24:15 +03:00
|
|
|
}
|
2023-09-30 07:20:31 +03:00
|
|
|
|
2023-10-30 03:49:10 +03:00
|
|
|
# rebase by X commits or from root. when COUNT is 0 - rebase from root. default is 2.
|
|
|
|
# usage: gr [COMMIT COUNT]
|
2023-09-30 07:20:31 +03:00
|
|
|
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
|
|
|
|
}
|
2023-10-12 13:06:34 +03:00
|
|
|
|
2023-10-26 22:12:08 +03:00
|
|
|
# specify git user as Dmitry Voronin with provided email.
|
|
|
|
# usage: gu [EMAIL]
|
2023-10-12 13:06:34 +03:00
|
|
|
gu()
|
|
|
|
{
|
2023-10-26 22:12:08 +03:00
|
|
|
local name="Dmitry Voronin"
|
|
|
|
local email="${1}"
|
2023-10-12 13:06:34 +03:00
|
|
|
|
|
|
|
if [[ "${name}" = "" || "${email}" = "" ]]; then
|
2023-10-26 22:12:08 +03:00
|
|
|
echo "usage: gu [EMAIL]"
|
2023-10-12 13:06:34 +03:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
git config user.name "${name}"
|
|
|
|
git config user.email "${email}"
|
|
|
|
}
|
2023-10-17 20:41:01 +03:00
|
|
|
|
2023-10-23 03:31:00 +03:00
|
|
|
# autocomplete.
|
2023-11-03 01:19:16 +03:00
|
|
|
_completion_loader git
|
|
|
|
__git_complete gps _git_push
|
|
|
|
__git_complete gpsf _git_push
|
|
|
|
__git_complete gpl _git_pull
|
|
|
|
__git_complete gl _git_log
|
|
|
|
__git_complete gs _git_status
|
|
|
|
__git_complete gst _git_stash
|
|
|
|
__git_complete gd _git_diff
|
|
|
|
__git_complete gc _git_commit
|
|
|
|
__git_complete gch _git_checkout
|
|
|
|
__git_complete gchb _git_checkout
|
|
|
|
__git_complete gb _git_branch
|
|
|
|
__git_complete gbd _git_branch
|
|
|
|
__git_complete gf _git_fetch
|
|
|
|
__git_complete gt _git_tag
|
|
|
|
__git_complete gp _git_apply
|
|
|
|
__git_complete ga _git_add
|
2023-10-26 22:12:08 +03:00
|
|
|
|
|
|
|
_gu()
|
|
|
|
{
|
2023-10-30 03:49:10 +03:00
|
|
|
_autocomplete_first account@voronind.com dd.voronin@fsight.ru
|
2023-10-26 22:12:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
complete -F _gu gu
|