├── LICENSE.txt ├── README.md └── git-aliases.zsh /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2009-2018 Robby Russell and contributors 4 | See the full list at https://github.com/robbyrussell/oh-my-zsh/contributors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # git plugin 2 | 3 | The git plugin provides many [aliases](#aliases) and a few useful [functions](#functions). 4 | 5 | To use it, add `git` to the plugins array in your zshrc file: 6 | 7 | ```zsh 8 | plugins=(... git) 9 | ``` 10 | 11 | ## Aliases 12 | 13 | | Alias | Command | 14 | |:---------------------|:---------------------------------------------------------------------------------------------------------------------------------| 15 | | g | git | 16 | | ga | git add | 17 | | gaa | git add --all | 18 | | gapa | git add --patch | 19 | | gau | git add --update | 20 | | gav | git add --verbose | 21 | | gap | git apply | 22 | | gapt | git apply --3way | 23 | | gb | git branch | 24 | | gba | git branch -a | 25 | | gbd | git branch -d | 26 | | gbda | git branch --no-color --merged \| command grep -vE "^(\+\|\*\|\s*($(git_main_branch)\|development\|develop\|devel\|dev)\s*$)" \| command xargs -n 1 git branch -d | 27 | | gbD | git branch -D | 28 | | gbl | git blame -b -w | 29 | | gbnm | git branch --no-merged | 30 | | gbr | git branch --remote | 31 | | gbs | git bisect | 32 | | gbsb | git bisect bad | 33 | | gbsg | git bisect good | 34 | | gbsr | git bisect reset | 35 | | gbss | git bisect start | 36 | | gc | git commit -v | 37 | | gc! | git commit -v --amend | 38 | | gcn! | git commit -v --no-edit --amend | 39 | | gca | git commit -v -a | 40 | | gca! | git commit -v -a --amend | 41 | | gcan! | git commit -v -a --no-edit --amend | 42 | | gcans! | git commit -v -a -s --no-edit --amend | 43 | | gcam | git commit -a -m | 44 | | gcas | git commit -a -s | 45 | | gcasm | git commit -a -s -m | 46 | | gcsm | git commit -s -m | 47 | | gcb | git checkout -b | 48 | | gcf | git config --list | 49 | | gcl | git clone --recurse-submodules | 50 | | gclean | git clean -id | 51 | | gpristine | git reset --hard && git clean -dffx | 52 | | gcm | git checkout $(git_main_branch) | 53 | | gcd | git checkout develop | 54 | | gcmsg | git commit -m | 55 | | gco | git checkout | 56 | | gcount | git shortlog -sn | 57 | | gcp | git cherry-pick | 58 | | gcpa | git cherry-pick --abort | 59 | | gcpc | git cherry-pick --continue | 60 | | gcs | git commit -S | 61 | | gd | git diff | 62 | | gdca | git diff --cached | 63 | | gdcw | git diff --cached --word-diff | 64 | | gdct | git describe --tags $(git rev-list --tags --max-count=1) | 65 | | gds | git diff --staged | 66 | | gdt | git diff-tree --no-commit-id --name-only -r | 67 | | gdnolock | git diff $@ ":(exclude)package-lock.json" ":(exclude)*.lock" | 68 | | gdv | git diff -w $@ \| view - | 69 | | gdw | git diff --word-diff | 70 | | gf | git fetch | 71 | | gfa | git fetch --all --prune | 72 | | gfg | git ls-files \| grep | 73 | | gfo | git fetch origin | 74 | | gg | git gui citool | 75 | | gga | git gui citool --amend | 76 | | ggf | git push --force origin $(current_branch) | 77 | | ggfl | git push --force-with-lease origin $(current_branch) | 78 | | ggl | git pull origin $(current_branch) | 79 | | ggp | git push origin $(current_branch) | 80 | | ggpnp | ggl && ggp | 81 | | ggpull | git pull origin "$(git_current_branch)" | 82 | | ggpur | ggu | 83 | | ggpush | git push origin "$(git_current_branch)" | 84 | | ggsup | git branch --set-upstream-to=origin/$(git_current_branch) | 85 | | ggu | git pull --rebase origin $(current_branch) | 86 | | gpsup | git push --set-upstream origin $(git_current_branch) | 87 | | ghh | git help | 88 | | gignore | git update-index --assume-unchanged | 89 | | gignored | git ls-files -v \| grep "^[[:lower:]]" | 90 | | git-svn-dcommit-push | git svn dcommit && git push github $(git_main_branch):svntrunk | 91 | | gk | gitk --all --branches | 92 | | gke | gitk --all $(git log -g --pretty=%h) | 93 | | gl | git pull | 94 | | glg | git log --stat | 95 | | glgp | git log --stat -p | 96 | | glgg | git log --graph | 97 | | glgga | git log --graph --decorate --all | 98 | | glgm | git log --graph --max-count=10 | 99 | | glo | git log --oneline --decorate | 100 | | glol | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' | 101 | | glols | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --stat | 102 | | glod | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' | 103 | | glods | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short | 104 | | glola | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all | 105 | | glog | git log --oneline --decorate --graph | 106 | | gloga | git log --oneline --decorate --graph --all | 107 | | glp | git log --pretty=\ | 108 | | gm | git merge | 109 | | gmom | git merge origin/$(git_main_branch) | 110 | | gmt | git mergetool --no-prompt | 111 | | gmtvim | git mergetool --no-prompt --tool=vimdiff | 112 | | gmum | git merge upstream/$(git_main_branch) | 113 | | gma | git merge --abort | 114 | | gp | git push | 115 | | gpd | git push --dry-run | 116 | | gpf | git push --force-with-lease | 117 | | gpf! | git push --force | 118 | | gpoat | git push origin --all && git push origin --tags | 119 | | gpu | git push upstream | 120 | | gpv | git push -v | 121 | | gr | git remote | 122 | | gra | git remote add | 123 | | grb | git rebase | 124 | | grba | git rebase --abort | 125 | | grbc | git rebase --continue | 126 | | grbd | git rebase develop | 127 | | grbi | git rebase -i | 128 | | grbm | git rebase $(git_main_branch) | 129 | | grbo | git rebase --onto | 130 | | grbs | git rebase --skip | 131 | | grev | git revert | 132 | | grh | git reset | 133 | | grhh | git reset --hard | 134 | | groh | git reset origin/$(git_current_branch) --hard | 135 | | grm | git rm | 136 | | grmc | git rm --cached | 137 | | grmv | git remote rename | 138 | | grrm | git remote remove | 139 | | grs | git restore | 140 | | grset | git remote set-url | 141 | | grss | git restore --source | 142 | | grst | git restore --staged | 143 | | grt | cd "$(git rev-parse --show-toplevel \|\| echo .)" | 144 | | gru | git reset -- | 145 | | grup | git remote update | 146 | | grv | git remote -v | 147 | | gsb | git status -sb | 148 | | gsd | git svn dcommit | 149 | | gsh | git show | 150 | | gsi | git submodule init | 151 | | gsps | git show --pretty=short --show-signature | 152 | | gsr | git svn rebase | 153 | | gss | git status -s | 154 | | gst | git status | 155 | | gsta | git stash push | 156 | | gsta | git stash save | 157 | | gstaa | git stash apply | 158 | | gstc | git stash clear | 159 | | gstd | git stash drop | 160 | | gstl | git stash list | 161 | | gstp | git stash pop | 162 | | gsts | git stash show --text | 163 | | gstu | git stash --include-untracked | 164 | | gstall | git stash --all | 165 | | gsu | git submodule update | 166 | | gsw | git switch | 167 | | gswc | git switch -c | 168 | | gts | git tag -s | 169 | | gtv | git tag \| sort -V | 170 | | gtl | gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl | 171 | | gunignore | git update-index --no-assume-unchanged | 172 | | gunwip | git log -n 1 \| grep -q -c "\-\-wip\-\-" && git reset HEAD~1 | 173 | | gup | git pull --rebase | 174 | | gupv | git pull --rebase -v | 175 | | gupa | git pull --rebase --autostash | 176 | | gupav | git pull --rebase --autostash -v | 177 | | glum | git pull upstream $(git_main_branch) | 178 | | gwch | git whatchanged -p --abbrev-commit --pretty=medium | 179 | | gwip | git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]" | 180 | | gam | git am | 181 | | gamc | git am --continue | 182 | | gams | git am --skip | 183 | | gama | git am --abort | 184 | | gamscp | git am --show-current-patch | 185 | 186 | ### Main branch preference 187 | 188 | Following the recent push for removing racially-charged words from our technical vocabulary, the git plugin favors using 189 | a branch name other than `master`. In this case, we favor the shorter, neutral and descriptive term `main`. This means 190 | that any aliases and functions that previously used `master`, will use `main` if that branch exists. We do this via the 191 | function `git_main_branch`. 192 | 193 | ### Deprecated aliases 194 | 195 | These are aliases that have been removed, renamed, or otherwise modified in a way that may, or may not, receive further support. 196 | 197 | | Alias | Command | Modification | 198 | | :----- | :----------------------------------------------------- | :----------------------------------------------------- | 199 | | gap | `git add --patch` | new alias `gapa` | 200 | | gcl | `git config --list` | new alias `gcf` | 201 | | gdc | `git diff --cached` | new alias `gdca` | 202 | | gdt | `git difftool` | no replacement | 203 | | ggpull | `git pull origin $(current_branch)` | new alias `ggl` (`ggpull` still exists for now though) | 204 | | ggpur | `git pull --rebase origin $(current_branch)` | new alias `ggu` (`ggpur` still exists for now though) | 205 | | ggpush | `git push origin $(current_branch)` | new alias `ggp` (`ggpush` still exists for now though) | 206 | | gk | `gitk --all --branches` | now aliased to `gitk --all --branches` | 207 | | glg | `git log --stat --max-count = 10` | now aliased to `git log --stat --color` | 208 | | glgg | `git log --graph --max-count = 10` | now aliased to `git log --graph --color` | 209 | | gwc | `git whatchanged -p --abbrev-commit --pretty = medium` | new alias `gwch` | 210 | 211 | ## Functions 212 | 213 | ### Current 214 | 215 | | Command | Description | 216 | |:-----------------------|:-----------------------------------------------------------------------------| 217 | | `grename ` | Rename `old` branch to `new`, including in origin remote | 218 | | current_branch | Return the name of the current branch | 219 | | git_current_user_name | Returns the `user.name` config value | 220 | | git_current_user_email | Returns the `user.email` config value | 221 | | git_main_branch | Returns the name of the main branch: `main` if it exists, `master` otherwise | 222 | 223 | ### Work in Progress (WIP) 224 | 225 | These features allow to pause a branch development and switch to another one (_"Work in Progress"_, or wip). When you want to go back to work, just unwip it. 226 | 227 | | Command | Description | 228 | |:-----------------|:------------------------------------------------| 229 | | work_in_progress | Echoes a warning if the current branch is a wip | 230 | | gwip | Commit wip branch | 231 | | gunwip | Uncommit wip branch | 232 | 233 | ### Deprecated functions 234 | 235 | | Command | Description | Reason | 236 | |:-----------------------|:----------------------------------------|:----------------------------------------------------------------| 237 | | current_repository | Return the names of the current remotes | Didn't work properly. Use `git remote -v` instead (`grv` alias) | 238 | -------------------------------------------------------------------------------- /git-aliases.zsh: -------------------------------------------------------------------------------- 1 | # Git version checking 2 | autoload -Uz is-at-least 3 | git_version="${${(As: :)$(git version 2>/dev/null)}[3]}" 4 | 5 | # 6 | # Functions 7 | # 8 | 9 | # The name of the current branch 10 | # Back-compatibility wrapper for when this function was defined here in 11 | # the plugin, before being pulled in to core lib/git.zsh as git_current_branch() 12 | # to fix the core -> git plugin dependency. 13 | function current_branch() { 14 | git_current_branch 15 | } 16 | 17 | # Pretty log messages 18 | function _git_log_prettily(){ 19 | if ! [ -z $1 ]; then 20 | git log --pretty=$1 21 | fi 22 | } 23 | compdef _git _git_log_prettily=git-log 24 | 25 | # Warn if the current branch is a WIP 26 | function work_in_progress() { 27 | if $(git log -n 1 2>/dev/null | grep -q -c "\-\-wip\-\-"); then 28 | echo "WIP!!" 29 | fi 30 | } 31 | 32 | # Check if main exists and use instead of master 33 | function git_main_branch() { 34 | command git rev-parse --git-dir &>/dev/null || return 35 | local branch 36 | for branch in main trunk; do 37 | if command git show-ref -q --verify refs/heads/$branch; then 38 | echo $branch 39 | return 40 | fi 41 | done 42 | echo master 43 | } 44 | 45 | # 46 | # Aliases 47 | # (sorted alphabetically) 48 | # 49 | 50 | alias g='git' 51 | 52 | alias ga='git add' 53 | alias gaa='git add --all' 54 | alias gapa='git add --patch' 55 | alias gau='git add --update' 56 | alias gav='git add --verbose' 57 | alias gap='git apply' 58 | alias gapt='git apply --3way' 59 | 60 | alias gb='git branch' 61 | alias gba='git branch -a' 62 | alias gbd='git branch -d' 63 | alias gbda='git branch --no-color --merged | command grep -vE "^(\+|\*|\s*($(git_main_branch)|development|develop|devel|dev)\s*$)" | command xargs -n 1 git branch -d' 64 | alias gbD='git branch -D' 65 | alias gbl='git blame -b -w' 66 | alias gbnm='git branch --no-merged' 67 | alias gbr='git branch --remote' 68 | alias gbs='git bisect' 69 | alias gbsb='git bisect bad' 70 | alias gbsg='git bisect good' 71 | alias gbsr='git bisect reset' 72 | alias gbss='git bisect start' 73 | 74 | alias gc='git commit -v' 75 | alias gc!='git commit -v --amend' 76 | alias gcn!='git commit -v --no-edit --amend' 77 | alias gca='git commit -v -a' 78 | alias gca!='git commit -v -a --amend' 79 | alias gcan!='git commit -v -a --no-edit --amend' 80 | alias gcans!='git commit -v -a -s --no-edit --amend' 81 | alias gcam='git commit -a -m' 82 | alias gcsm='git commit -s -m' 83 | alias gcas='git commit -a -s' 84 | alias gcasm='git commit -a -s -m' 85 | alias gcb='git checkout -b' 86 | alias gcf='git config --list' 87 | alias gcl='git clone --recurse-submodules' 88 | alias gclean='git clean -id' 89 | alias gpristine='git reset --hard && git clean -dffx' 90 | alias gcm='git checkout $(git_main_branch)' 91 | alias gcd='git checkout develop' 92 | alias gcmsg='git commit -m' 93 | alias gco='git checkout' 94 | alias gcount='git shortlog -sn' 95 | alias gcp='git cherry-pick' 96 | alias gcpa='git cherry-pick --abort' 97 | alias gcpc='git cherry-pick --continue' 98 | alias gcs='git commit -S' 99 | 100 | alias gd='git diff' 101 | alias gdca='git diff --cached' 102 | alias gdcw='git diff --cached --word-diff' 103 | alias gdct='git describe --tags $(git rev-list --tags --max-count=1)' 104 | alias gds='git diff --staged' 105 | alias gdt='git diff-tree --no-commit-id --name-only -r' 106 | alias gdw='git diff --word-diff' 107 | 108 | function gdnolock() { 109 | git diff "$@" ":(exclude)package-lock.json" ":(exclude)*.lock" 110 | } 111 | compdef _git gdnolock=git-diff 112 | 113 | function gdv() { git diff -w "$@" | view - } 114 | compdef _git gdv=git-diff 115 | 116 | alias gf='git fetch' 117 | # --jobs= was added in git 2.8 118 | is-at-least 2.8 "$git_version" \ 119 | && alias gfa='git fetch --all --prune --jobs=10' \ 120 | || alias gfa='git fetch --all --prune' 121 | alias gfo='git fetch origin' 122 | 123 | alias gfg='git ls-files | grep' 124 | 125 | alias gg='git gui citool' 126 | alias gga='git gui citool --amend' 127 | 128 | function ggf() { 129 | [[ "$#" != 1 ]] && local b="$(git_current_branch)" 130 | git push --force origin "${b:=$1}" 131 | } 132 | compdef _git ggf=git-checkout 133 | function ggfl() { 134 | [[ "$#" != 1 ]] && local b="$(git_current_branch)" 135 | git push --force-with-lease origin "${b:=$1}" 136 | } 137 | compdef _git ggfl=git-checkout 138 | 139 | function ggl() { 140 | if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then 141 | git pull origin "${*}" 142 | else 143 | [[ "$#" == 0 ]] && local b="$(git_current_branch)" 144 | git pull origin "${b:=$1}" 145 | fi 146 | } 147 | compdef _git ggl=git-checkout 148 | 149 | function ggp() { 150 | if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then 151 | git push origin "${*}" 152 | else 153 | [[ "$#" == 0 ]] && local b="$(git_current_branch)" 154 | git push origin "${b:=$1}" 155 | fi 156 | } 157 | compdef _git ggp=git-checkout 158 | 159 | function ggpnp() { 160 | if [[ "$#" == 0 ]]; then 161 | ggl && ggp 162 | else 163 | ggl "${*}" && ggp "${*}" 164 | fi 165 | } 166 | compdef _git ggpnp=git-checkout 167 | 168 | function ggu() { 169 | [[ "$#" != 1 ]] && local b="$(git_current_branch)" 170 | git pull --rebase origin "${b:=$1}" 171 | } 172 | compdef _git ggu=git-checkout 173 | 174 | alias ggpur='ggu' 175 | alias ggpull='git pull origin "$(git_current_branch)"' 176 | alias ggpush='git push origin "$(git_current_branch)"' 177 | 178 | alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)' 179 | alias gpsup='git push --set-upstream origin $(git_current_branch)' 180 | 181 | alias ghh='git help' 182 | 183 | alias gignore='git update-index --assume-unchanged' 184 | alias gignored='git ls-files -v | grep "^[[:lower:]]"' 185 | alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk' 186 | 187 | alias gk='\gitk --all --branches' 188 | alias gke='\gitk --all $(git log -g --pretty=%h)' 189 | 190 | alias gl='git pull' 191 | alias glg='git log --stat' 192 | alias glgp='git log --stat -p' 193 | alias glgg='git log --graph' 194 | alias glgga='git log --graph --decorate --all' 195 | alias glgm='git log --graph --max-count=10' 196 | alias glo='git log --oneline --decorate' 197 | alias glol="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'" 198 | alias glols="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --stat" 199 | alias glod="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'" 200 | alias glods="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short" 201 | alias glola="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all" 202 | alias glog='git log --oneline --decorate --graph' 203 | alias gloga='git log --oneline --decorate --graph --all' 204 | alias glp="_git_log_prettily" 205 | 206 | alias gm='git merge' 207 | alias gmom='git merge origin/$(git_main_branch)' 208 | alias gmt='git mergetool --no-prompt' 209 | alias gmtvim='git mergetool --no-prompt --tool=vimdiff' 210 | alias gmum='git merge upstream/$(git_main_branch)' 211 | alias gma='git merge --abort' 212 | 213 | alias gp='git push' 214 | alias gpd='git push --dry-run' 215 | alias gpf='git push --force-with-lease' 216 | alias gpf!='git push --force' 217 | alias gpoat='git push origin --all && git push origin --tags' 218 | alias gpu='git push upstream' 219 | alias gpv='git push -v' 220 | 221 | alias gr='git remote' 222 | alias gra='git remote add' 223 | alias grb='git rebase' 224 | alias grba='git rebase --abort' 225 | alias grbc='git rebase --continue' 226 | alias grbd='git rebase develop' 227 | alias grbi='git rebase -i' 228 | alias grbm='git rebase $(git_main_branch)' 229 | alias grbo='git rebase --onto' 230 | alias grbs='git rebase --skip' 231 | alias grev='git revert' 232 | alias grh='git reset' 233 | alias grhh='git reset --hard' 234 | alias groh='git reset origin/$(git_current_branch) --hard' 235 | alias grm='git rm' 236 | alias grmc='git rm --cached' 237 | alias grmv='git remote rename' 238 | alias grrm='git remote remove' 239 | alias grs='git restore' 240 | alias grset='git remote set-url' 241 | alias grss='git restore --source' 242 | alias grst='git restore --staged' 243 | alias grt='cd "$(git rev-parse --show-toplevel || echo .)"' 244 | alias gru='git reset --' 245 | alias grup='git remote update' 246 | alias grv='git remote -v' 247 | 248 | alias gsb='git status -sb' 249 | alias gsd='git svn dcommit' 250 | alias gsh='git show' 251 | alias gsi='git submodule init' 252 | alias gsps='git show --pretty=short --show-signature' 253 | alias gsr='git svn rebase' 254 | alias gss='git status -s' 255 | alias gst='git status' 256 | 257 | # use the default stash push on git 2.13 and newer 258 | is-at-least 2.13 "$git_version" \ 259 | && alias gsta='git stash push' \ 260 | || alias gsta='git stash save' 261 | 262 | alias gstaa='git stash apply' 263 | alias gstc='git stash clear' 264 | alias gstd='git stash drop' 265 | alias gstl='git stash list' 266 | alias gstp='git stash pop' 267 | alias gsts='git stash show --text' 268 | alias gstu='gsta --include-untracked' 269 | alias gstall='git stash --all' 270 | alias gsu='git submodule update' 271 | alias gsw='git switch' 272 | alias gswc='git switch -c' 273 | 274 | alias gts='git tag -s' 275 | alias gtv='git tag | sort -V' 276 | alias gtl='gtl(){ git tag --sort=-v:refname -n -l "${1}*" }; noglob gtl' 277 | 278 | alias gunignore='git update-index --no-assume-unchanged' 279 | alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1' 280 | alias gup='git pull --rebase' 281 | alias gupv='git pull --rebase -v' 282 | alias gupa='git pull --rebase --autostash' 283 | alias gupav='git pull --rebase --autostash -v' 284 | alias glum='git pull upstream $(git_main_branch)' 285 | 286 | alias gwch='git whatchanged -p --abbrev-commit --pretty=medium' 287 | alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]"' 288 | 289 | alias gam='git am' 290 | alias gamc='git am --continue' 291 | alias gams='git am --skip' 292 | alias gama='git am --abort' 293 | alias gamscp='git am --show-current-patch' 294 | 295 | function grename() { 296 | if [[ -z "$1" || -z "$2" ]]; then 297 | echo "Usage: $0 old_branch new_branch" 298 | return 1 299 | fi 300 | 301 | # Rename branch locally 302 | git branch -m "$1" "$2" 303 | # Rename branch in origin remote 304 | if git push origin :"$1"; then 305 | git push --set-upstream origin "$2" 306 | fi 307 | } 308 | 309 | unset git_version 310 | --------------------------------------------------------------------------------