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'
|
2024-09-18 14:25:01 +00:00
|
|
|
if exist lazygit; then
|
|
|
|
alias lg="lazygit"
|
|
|
|
fi
|
2020-05-28 11:29:49 +00:00
|
|
|
|
|
|
|
alias ga='git add'
|
|
|
|
alias gaa='git add --all'
|
|
|
|
alias gai='git add -i'
|
|
|
|
|
|
|
|
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'
|
2023-12-12 11:29:40 +00:00
|
|
|
gcb() {
|
|
|
|
git switch "$@" 2>/dev/null || git switch -c "$@"
|
|
|
|
}
|
2021-11-23 09:33:37 +00:00
|
|
|
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 gi='git ignore'
|
|
|
|
|
2023-12-12 11:19:41 +00:00
|
|
|
# normal diff
|
|
|
|
alias gd='git diff'
|
|
|
|
alias gds='git diff --staged'
|
2023-12-12 11:17:19 +00:00
|
|
|
# word-based diff (with custom word regex)
|
|
|
|
alias gdw='git diffword'
|
|
|
|
alias gdws='git diffword --staged'
|
|
|
|
# side-by-side diff
|
|
|
|
alias gdd='git diffside'
|
|
|
|
alias gdds='git diffside --staged'
|
2023-12-12 11:15:07 +00:00
|
|
|
# syntax-based diff
|
|
|
|
if exist difft; then
|
|
|
|
alias gdy='git diffsyn'
|
|
|
|
alias gdys='git diffsyn --staged'
|
|
|
|
fi
|
2023-12-12 11:19:41 +00:00
|
|
|
alias gdd='git diffside'
|
|
|
|
alias gdds='git diffside --staged'
|
2020-05-28 12:01:50 +00:00
|
|
|
# show last committed content
|
2023-12-12 11:15:07 +00:00
|
|
|
alias gdl='git last'
|
2023-12-12 11:19:41 +00:00
|
|
|
|
2020-05-28 12:01:50 +00:00
|
|
|
# show quick log overview
|
2020-05-28 11:29:49 +00:00
|
|
|
alias glg='git log --oneline --decorate --graph'
|
|
|
|
alias glga='git log --oneline --decorate --graph --remotes --all'
|
2023-12-12 11:19:41 +00:00
|
|
|
# show quick log overview - with dates
|
|
|
|
alias glgd="git log --graph --pretty=format:'%C(auto)%h%Creset %C(cyan)%ar%Creset%C(auto)%d%Creset %s'"
|
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
|
|
|
|
|
2024-02-04 20:25:21 +00:00
|
|
|
if exist git-bug; then
|
|
|
|
gb() {
|
|
|
|
if [ "$#" -eq 1 ]; then
|
|
|
|
git bug show "$1"
|
|
|
|
else
|
|
|
|
git bug ls "$@"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
alias gbt='git bug termui'
|
|
|
|
|
|
|
|
alias gba='git bug add'
|
|
|
|
alias gbm='git bug comment add'
|
|
|
|
alias gbc='git bug status close'
|
|
|
|
|
|
|
|
alias gbp='git bug push'
|
|
|
|
alias gbl='git bug pull'
|
|
|
|
fi
|
|
|
|
|
2021-11-23 09:33:37 +00:00
|
|
|
unset -v git_version
|