]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/plugins/git/README.md
...
[dotfiles.git] / stow / oh-my-zsh / .oh-my-zsh / plugins / git / 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 \| grep -vE "^([+*]\|\s*(<span>$</span>(git_main_branch)\|<span>$</span>(git_develop_branch))\s*<span>$</span>)" \| xargs git branch -d 2>/dev/null |
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 | gccd                 | git clone --recurse-submodules "<span>$</span>@" && cd "<span>$</span>(basename <span>$</span>_ .git)"                           |
51 | gclean               | git clean -id                                                                                                                    |
52 | gpristine            | git reset --hard && git clean -dffx                                                                                              |
53 | gcm                  | git checkout $(git_main_branch)                                                                                                  |
54 | gcd                  | git checkout $(git_develop_branch)                                                                                               |
55 | gcmsg                | git commit -m                                                                                                                    |
56 | gco                  | git checkout                                                                                                                     |
57 | gcor                 | git checkout --recurse-submodules                                                                                                |
58 | gcount               | git shortlog -sn                                                                                                                 |
59 | gcp                  | git cherry-pick                                                                                                                  |
60 | gcpa                 | git cherry-pick --abort                                                                                                          |
61 | gcpc                 | git cherry-pick --continue                                                                                                       |
62 | gcs                  | git commit -S                                                                                                                    |
63 | gd                   | git diff                                                                                                                         |
64 | gdca                 | git diff --cached                                                                                                                |
65 | gdcw                 | git diff --cached --word-diff                                                                                                    |
66 | gdct                 | git describe --tags $(git rev-list --tags --max-count=1)                                                                         |
67 | gds                  | git diff --staged                                                                                                                |
68 | gdt                  | git diff-tree --no-commit-id --name-only -r                                                                                      |
69 | gdnolock             | git diff $@ ":(exclude)package-lock.json" ":(exclude)&ast;.lock"                                                                 |
70 | gdup                 | git diff @{upstream}                                                                                                             |
71 | gdv                  | git diff -w $@ \| view -                                                                                                         |
72 | gdw                  | git diff --word-diff                                                                                                             |
73 | gf                   | git fetch                                                                                                                        |
74 | gfa                  | git fetch --all --prune                                                                                                          |
75 | gfg                  | git ls-files \| grep                                                                                                             |
76 | gfo                  | git fetch origin                                                                                                                 |
77 | gg                   | git gui citool                                                                                                                   |
78 | gga                  | git gui citool --amend                                                                                                           |
79 | ggf                  | git push --force origin $(current_branch)                                                                                        |
80 | ggfl                 | git push --force-with-lease origin $(current_branch)                                                                             |
81 | ggl                  | git pull origin $(current_branch)                                                                                                |
82 | ggp                  | git push origin $(current_branch)                                                                                                |
83 | ggpnp                | ggl && ggp                                                                                                                       |
84 | ggpull               | git pull origin "$(git_current_branch)"                                                                                          |
85 | ggpur                | ggu                                                                                                                              |
86 | ggpush               | git push origin "$(git_current_branch)"                                                                                          |
87 | ggsup                | git branch --set-upstream-to=origin/$(git_current_branch)                                                                        |
88 | ggu                  | git pull --rebase origin $(current_branch)                                                                                       |
89 | gpsup                | git push --set-upstream origin $(git_current_branch)                                                                             |
90 | ghh                  | git help                                                                                                                         |
91 | gignore              | git update-index --assume-unchanged                                                                                              |
92 | gignored             | git ls-files -v \| grep "^[[:lower:]]"                                                                                           |
93 | git-svn-dcommit-push | git svn dcommit && git push github $(git_main_branch):svntrunk                                                                   |
94 | gk                   | gitk --all --branches &!                                                                                                          |
95 | gke                  | gitk --all $(git log -g --pretty=%h) &!                                                                                           |
96 | gl                   | git pull                                                                                                                         |
97 | glg                  | git log --stat                                                                                                                   |
98 | glgp                 | git log --stat -p                                                                                                                |
99 | glgg                 | git log --graph                                                                                                                  |
100 | glgga                | git log --graph --decorate --all                                                                                                 |
101 | glgm                 | git log --graph --max-count=10                                                                                                   |
102 | glo                  | git log --oneline --decorate                                                                                                     |
103 | glol                 | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'                           |
104 | glols                | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat                    |
105 | glod                 | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'                           |
106 | glods                | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short              |
107 | glola                | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all                     |
108 | glog                 | git log --oneline --decorate --graph                                                                                             |
109 | gloga                | git log --oneline --decorate --graph --all                                                                                       |
110 | glp                  | git log --pretty=\<format\>                                                                                                      |
111 | gm                   | git merge                                                                                                                        |
112 | gmom                 | git merge origin/$(git_main_branch)                                                                                              |
113 | gmtl                 | git mergetool --no-prompt                                                                                                        |
114 | gmtlvim              | git mergetool --no-prompt --tool=vimdiff                                                                                         |
115 | gmum                 | git merge upstream/$(git_main_branch)                                                                                            |
116 | gma                  | git merge --abort                                                                                                                |
117 | gp                   | git push                                                                                                                         |
118 | gpd                  | git push --dry-run                                                                                                               |
119 | gpf                  | git push --force-with-lease                                                                                                      |
120 | gpf!                 | git push --force                                                                                                                 |
121 | gpoat                | git push origin --all && git push origin --tags                                                                                  |
122 | gpr                  | git pull --rebase                                                                                                                |
123 | gpu                  | git push upstream                                                                                                                |
124 | gpv                  | git push -v                                                                                                                      |
125 | gr                   | git remote                                                                                                                       |
126 | gra                  | git remote add                                                                                                                   |
127 | grb                  | git rebase                                                                                                                       |
128 | grba                 | git rebase --abort                                                                                                               |
129 | grbc                 | git rebase --continue                                                                                                            |
130 | grbd                 | git rebase $(git_develop_branch)                                                                                                 |
131 | grbi                 | git rebase -i                                                                                                                    |
132 | grbm                 | git rebase $(git_main_branch)                                                                                                    |
133 | grbom                | git rebase origin/$(git_main_branch)                                                                                             |
134 | grbo                 | git rebase --onto                                                                                                                |
135 | grbs                 | git rebase --skip                                                                                                                |
136 | grev                 | git revert                                                                                                                       |
137 | grh                  | git reset                                                                                                                        |
138 | grhh                 | git reset --hard                                                                                                                 |
139 | groh                 | git reset origin/$(git_current_branch) --hard                                                                                    |
140 | grm                  | git rm                                                                                                                           |
141 | grmc                 | git rm --cached                                                                                                                  |
142 | grmv                 | git remote rename                                                                                                                |
143 | grrm                 | git remote remove                                                                                                                |
144 | grs                  | git restore                                                                                                                      |
145 | grset                | git remote set-url                                                                                                               |
146 | grss                 | git restore --source                                                                                                             |
147 | grst                 | git restore --staged                                                                                                             |
148 | grt                  | cd "$(git rev-parse --show-toplevel \|\| echo .)"                                                                                |
149 | gru                  | git reset --                                                                                                                     |
150 | grup                 | git remote update                                                                                                                |
151 | grv                  | git remote -v                                                                                                                    |
152 | gsb                  | git status -sb                                                                                                                   |
153 | gsd                  | git svn dcommit                                                                                                                  |
154 | gsh                  | git show                                                                                                                         |
155 | gsi                  | git submodule init                                                                                                               |
156 | gsps                 | git show --pretty=short --show-signature                                                                                         |
157 | gsr                  | git svn rebase                                                                                                                   |
158 | gss                  | git status -s                                                                                                                    |
159 | gst                  | git status                                                                                                                       |
160 | gsta                 | git stash push                                                                                                                   |
161 | gsta                 | git stash save                                                                                                                   |
162 | gstaa                | git stash apply                                                                                                                  |
163 | gstc                 | git stash clear                                                                                                                  |
164 | gstd                 | git stash drop                                                                                                                   |
165 | gstl                 | git stash list                                                                                                                   |
166 | gstp                 | git stash pop                                                                                                                    |
167 | gsts                 | git stash show --text                                                                                                            |
168 | gstu                 | git stash --include-untracked                                                                                                    |
169 | gstall               | git stash --all                                                                                                                  |
170 | gsu                  | git submodule update                                                                                                             |
171 | gsw                  | git switch                                                                                                                       |
172 | gswc                 | git switch -c                                                                                                                    |
173 | gswm                 | git switch $(git_main_branch)                                                                                                    |
174 | gswd                 | git switch $(git_develop_branch)                                                                                                 |
175 | gts                  | git tag -s                                                                                                                       |
176 | gtv                  | git tag \| sort -V                                                                                                               |
177 | gtl                  | gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl                                                                       |
178 | gunignore            | git update-index --no-assume-unchanged                                                                                           |
179 | gunwip               | git log -n 1 \| grep -q -c "\-\-wip\-\-" && git reset HEAD~1                                                                     |
180 | gup                  | git pull --rebase                                                                                                                |
181 | gupv                 | git pull --rebase -v                                                                                                             |
182 | gupa                 | git pull --rebase --autostash                                                                                                    |
183 | gupav                | git pull --rebase --autostash -v                                                                                                 |
184 | gupom                | git pull --rebase origin $(git_main_branch)                                                                                      |
185 | gupomi               | git pull --rebase=interactive origin $(git_main_branch)                                                                          |
186 | glum                 | git pull upstream $(git_main_branch)                                                                                             |
187 | gluc                 | git pull upstream $(git_current_branch)                                                                                             |
188 | gwch                 | git whatchanged -p --abbrev-commit --pretty=medium                                                                               |
189 | gwip                 | git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]"           |
190 | gam                  | git am                                                                                                                           |
191 | gamc                 | git am --continue                                                                                                                |
192 | gams                 | git am --skip                                                                                                                    |
193 | gama                 | git am --abort                                                                                                                   |
194 | gamscp               | git am --show-current-patch                                                                                                      |
195
196 ### Main branch preference
197
198 Following the recent push for removing racially-charged words from our technical vocabulary, the git plugin favors using
199 a branch name other than `master`. In this case, we favor the shorter, neutral and descriptive term `main`. This means
200 that any aliases and functions that previously used `master`, will use `main` if that branch exists. We do this via the
201 function `git_main_branch`.
202
203 ### Deprecated aliases
204
205 These are aliases that have been removed, renamed, or otherwise modified in a way that may, or may not, receive further support.
206
207 | Alias  | Command                                                | Modification                                           |
208 | :----- | :----------------------------------------------------- | :----------------------------------------------------- |
209 | gap    | `git add --patch`                                      | new alias `gapa`                                       |
210 | gcl    | `git config --list`                                    | new alias `gcf`                                        |
211 | gdc    | `git diff --cached`                                    | new alias `gdca`                                       |
212 | gdt    | `git difftool`                                         | no replacement                                         |
213 | ggpull | `git pull origin $(current_branch)`                    | new alias `ggl` (`ggpull` still exists for now though) |
214 | ggpur  | `git pull --rebase origin $(current_branch)`           | new alias `ggu` (`ggpur` still exists for now though)  |
215 | ggpush | `git push origin $(current_branch)`                    | new alias `ggp` (`ggpush` still exists for now though) |
216 | gk     | `gitk --all --branches`                                | now aliased to `gitk --all --branches`                 |
217 | glg    | `git log --stat --max-count = 10`                      | now aliased to `git log --stat --color`                |
218 | glgg   | `git log --graph --max-count = 10`                     | now aliased to `git log --graph --color`               |
219 | gwc    | `git whatchanged -p --abbrev-commit --pretty = medium` | new alias `gwch`                                       |
220
221 ## Functions
222
223 ### Current
224
225 | Command                | Description                                                                                              |
226 |:-----------------------|:---------------------------------------------------------------------------------------------------------|
227 | `grename <old> <new>`  | Rename `old` branch to `new`, including in origin remote                                                 |
228 | current_branch         | Return the name of the current branch                                                                    |
229 | git_current_user_name  | Returns the `user.name` config value                                                                     |
230 | git_current_user_email | Returns the `user.email` config value                                                                    |
231 | git_main_branch        | Returns the name of the main branch: `main` if it exists, `master` otherwise                             |
232 | git_develop_branch     | Returns the name of the develop branch: `dev`, `devel`, `development` if they exist, `develop` otherwise |
233
234 ### Work in Progress (WIP)
235
236 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.
237
238 | Command          | Description                                     |
239 |:-----------------|:------------------------------------------------|
240 | work_in_progress | Echoes a warning if the current branch is a wip |
241 | gwip             | Commit wip branch                               |
242 | gunwip           | Uncommit wip branch                             |
243
244 ### Deprecated functions
245
246 | Command                | Description                             | Reason                                                          |
247 |:-----------------------|:----------------------------------------|:----------------------------------------------------------------|
248 | current_repository     | Return the names of the current remotes | Didn't work properly. Use `git remote -v` instead (`grv` alias) |