2020-02-04 14:27:44 +00:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
2020-05-28 11:29:49 +00:00
|
|
|
if ! exist git; then
|
2021-04-04 18:52:52 +00:00
|
|
|
return 1
|
2020-02-04 09:06:33 +00:00
|
|
|
fi
|
2020-05-28 11:29:49 +00:00
|
|
|
|
2021-11-23 09:33:37 +00:00
|
|
|
# print git version output and get raw version number by stripping prefix
|
|
|
|
git_version=$(git --version 2>/dev/null)
|
|
|
|
git_version="${git_version##git version }"
|
2020-05-28 11:29:49 +00:00
|
|
|
|
|
|
|
alias g='git'
|
|
|
|
|
|
|
|
alias ga='git add'
|
|
|
|
alias gaa='git add --all'
|
|
|
|
alias gai='git add -i'
|
|
|
|
alias gb='git branch'
|
|
|
|
alias gbd='git branch -d'
|
|
|
|
|
|
|
|
alias gc='git commit -v'
|
|
|
|
alias gc!='git commit -v --amend'
|
|
|
|
alias gcn!='git commit -v --no-edit --amend'
|
|
|
|
|
2021-11-23 09:33:37 +00:00
|
|
|
if version_at_least 2.23 "$git_version"; then
|
|
|
|
alias gcm='git switch master 2>/dev/null || git switch main'
|
2022-01-28 09:14:20 +00:00
|
|
|
alias gcd='git switch develop 2>/dev/null || git switch staging'
|
2021-11-23 09:33:37 +00:00
|
|
|
alias gcb='git switch -c'
|
|
|
|
else
|
|
|
|
alias gcm='git checkout master 2>/dev/null || git checkout main'
|
|
|
|
alias gcd='git checkout develop'
|
|
|
|
alias gcb='git checkout -b'
|
|
|
|
fi
|
2021-12-04 10:23:03 +00:00
|
|
|
alias gco='git checkout'
|
2020-05-28 11:29:49 +00:00
|
|
|
|
|
|
|
alias gd='git diff'
|
2023-10-05 16:09:48 +00:00
|
|
|
alias gdd='git diffword'
|
2020-05-28 11:29:49 +00:00
|
|
|
alias gds='git diff --staged'
|
2023-10-05 16:09:48 +00:00
|
|
|
alias gdds='git diffword --staged'
|
2020-05-28 11:29:49 +00:00
|
|
|
|
|
|
|
alias gi='git ignore'
|
|
|
|
|
2020-05-28 12:01:50 +00:00
|
|
|
# show last committed content
|
|
|
|
alias gll='git last'
|
|
|
|
# show quick log overview
|
2020-05-28 11:29:49 +00:00
|
|
|
alias glg='git log --oneline --decorate --graph'
|
2023-10-02 17:10:27 +00:00
|
|
|
alias glgd="git log --graph --pretty=format:'%C(auto)%h%Creset %C(cyan)%ar%Creset%C(auto)%d%Creset %s'"
|
2020-05-28 11:29:49 +00:00
|
|
|
alias glga='git log --oneline --decorate --graph --remotes --all'
|
2023-10-02 17:10:27 +00:00
|
|
|
alias glgad="git log --graph --remotes --all --pretty=format:'%C(auto)%h%Creset %C(cyan)%ar%Creset%C(auto)%d%Creset %s'"
|
2020-05-28 12:01:50 +00:00
|
|
|
# show detailed log overview
|
|
|
|
alias glog='git log --stat'
|
|
|
|
# show detailed log overview with contents
|
|
|
|
alias gloog='git log --stat -p'
|
2020-05-28 11:29:49 +00:00
|
|
|
|
|
|
|
alias gf='git fetch'
|
2022-11-04 14:14:54 +00:00
|
|
|
alias gfa='git fetchall'
|
2020-05-28 11:29:49 +00:00
|
|
|
alias gl='git pull'
|
|
|
|
|
|
|
|
alias gpn='git push --dry-run'
|
|
|
|
alias gp='git push'
|
|
|
|
alias gpf!='git push --force'
|
|
|
|
alias gpm='git pushmerge'
|
2020-09-18 15:12:21 +00:00
|
|
|
alias gpa='git pushall'
|
2020-05-28 11:29:49 +00:00
|
|
|
|
|
|
|
alias grv='git remote -v'
|
|
|
|
|
|
|
|
alias grs='git restore --staged'
|
|
|
|
alias grs!='git restore'
|
|
|
|
|
2020-09-18 15:17:48 +00:00
|
|
|
alias grb='git rebase'
|
2020-05-28 11:29:49 +00:00
|
|
|
alias grbi='git rebase -i'
|
|
|
|
alias grbc='git rebase --continue'
|
2021-03-14 12:02:47 +00:00
|
|
|
alias grbm='git rebase master || git rebase main'
|
2020-05-28 11:29:49 +00:00
|
|
|
|
|
|
|
alias gst='git status'
|
|
|
|
|
|
|
|
alias gstp='git stash pop'
|
|
|
|
alias gstl='git stash list'
|
|
|
|
alias gstL='git stash list --stat'
|
2021-11-23 09:33:37 +00:00
|
|
|
if version_at_least 2.13 "$git_version"; then
|
|
|
|
alias gsta='git stash push'
|
|
|
|
else
|
|
|
|
alias gsta='git stash save'
|
|
|
|
fi
|
|
|
|
|
|
|
|
unset -v git_version
|