my xfce4 dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

245 lines
32 KiB

3 years ago
  1. # git plugin
  2. The git plugin provides many [aliases](#aliases) and a few useful [functions](#functions).
  3. To use it, add `git` to the plugins array in your zshrc file:
  4. ```zsh
  5. plugins=(... git)
  6. ```
  7. ## Aliases
  8. | Alias | Command |
  9. |:---------------------|:---------------------------------------------------------------------------------------------------------------------------------|
  10. | g | git |
  11. | ga | git add |
  12. | gaa | git add --all |
  13. | gapa | git add --patch |
  14. | gau | git add --update |
  15. | gav | git add --verbose |
  16. | gap | git apply |
  17. | gapt | git apply --3way |
  18. | gb | git branch |
  19. | gba | git branch -a |
  20. | gbd | git branch -d |
  21. | gbda | git branch --no-color --merged \| grep -vE "^([+*]\|\s*($(git_main_branch)\|$(git_develop_branch))\s*$)" \| xargs git branch -d 2>/dev/null |
  22. | gbD | git branch -D |
  23. | gbl | git blame -b -w |
  24. | gbnm | git branch --no-merged |
  25. | gbr | git branch --remote |
  26. | gbs | git bisect |
  27. | gbsb | git bisect bad |
  28. | gbsg | git bisect good |
  29. | gbsr | git bisect reset |
  30. | gbss | git bisect start |
  31. | gc | git commit -v |
  32. | gc! | git commit -v --amend |
  33. | gcn! | git commit -v --no-edit --amend |
  34. | gca | git commit -v -a |
  35. | gca! | git commit -v -a --amend |
  36. | gcan! | git commit -v -a --no-edit --amend |
  37. | gcans! | git commit -v -a -s --no-edit --amend |
  38. | gcam | git commit -a -m |
  39. | gcas | git commit -a -s |
  40. | gcasm | git commit -a -s -m |
  41. | gcsm | git commit -s -m |
  42. | gcb | git checkout -b |
  43. | gcf | git config --list |
  44. | gcl | git clone --recurse-submodules |
  45. | gccd | git clone --recurse-submodules "$@" && cd "$(basename $_ .git)" |
  46. | gclean | git clean -id |
  47. | gpristine | git reset --hard && git clean -dffx |
  48. | gcm | git checkout $(git_main_branch) |
  49. | gcd | git checkout $(git_develop_branch) |
  50. | gcmsg | git commit -m |
  51. | gco | git checkout |
  52. | gcor | git checkout --recurse-submodules |
  53. | gcount | git shortlog -sn |
  54. | gcp | git cherry-pick |
  55. | gcpa | git cherry-pick --abort |
  56. | gcpc | git cherry-pick --continue |
  57. | gcs | git commit -S |
  58. | gd | git diff |
  59. | gdca | git diff --cached |
  60. | gdcw | git diff --cached --word-diff |
  61. | gdct | git describe --tags $(git rev-list --tags --max-count=1) |
  62. | gds | git diff --staged |
  63. | gdt | git diff-tree --no-commit-id --name-only -r |
  64. | gdnolock | git diff $@ ":(exclude)package-lock.json" ":(exclude)*.lock" |
  65. | gdup | git diff @{upstream} |
  66. | gdv | git diff -w $@ \| view - |
  67. | gdw | git diff --word-diff |
  68. | gf | git fetch |
  69. | gfa | git fetch --all --prune |
  70. | gfg | git ls-files \| grep |
  71. | gfo | git fetch origin |
  72. | gg | git gui citool |
  73. | gga | git gui citool --amend |
  74. | ggf | git push --force origin $(current_branch) |
  75. | ggfl | git push --force-with-lease origin $(current_branch) |
  76. | ggl | git pull origin $(current_branch) |
  77. | ggp | git push origin $(current_branch) |
  78. | ggpnp | ggl && ggp |
  79. | ggpull | git pull origin "$(git_current_branch)" |
  80. | ggpur | ggu |
  81. | ggpush | git push origin "$(git_current_branch)" |
  82. | ggsup | git branch --set-upstream-to=origin/$(git_current_branch) |
  83. | ggu | git pull --rebase origin $(current_branch) |
  84. | gpsup | git push --set-upstream origin $(git_current_branch) |
  85. | ghh | git help |
  86. | gignore | git update-index --assume-unchanged |
  87. | gignored | git ls-files -v \| grep "^[[:lower:]]" |
  88. | git-svn-dcommit-push | git svn dcommit && git push github $(git_main_branch):svntrunk |
  89. | gk | gitk --all --branches &! |
  90. | gke | gitk --all $(git log -g --pretty=%h) &! |
  91. | gl | git pull |
  92. | glg | git log --stat |
  93. | glgp | git log --stat -p |
  94. | glgg | git log --graph |
  95. | glgga | git log --graph --decorate --all |
  96. | glgm | git log --graph --max-count=10 |
  97. | glo | git log --oneline --decorate |
  98. | glol | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' |
  99. | glols | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat |
  100. | glod | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' |
  101. | glods | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short |
  102. | glola | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all |
  103. | glog | git log --oneline --decorate --graph |
  104. | gloga | git log --oneline --decorate --graph --all |
  105. | glp | git log --pretty=\<format\> |
  106. | gm | git merge |
  107. | gmom | git merge origin/$(git_main_branch) |
  108. | gmtl | git mergetool --no-prompt |
  109. | gmtlvim | git mergetool --no-prompt --tool=vimdiff |
  110. | gmum | git merge upstream/$(git_main_branch) |
  111. | gma | git merge --abort |
  112. | gp | git push |
  113. | gpd | git push --dry-run |
  114. | gpf | git push --force-with-lease |
  115. | gpf! | git push --force |
  116. | gpoat | git push origin --all && git push origin --tags |
  117. | gpr | git pull --rebase |
  118. | gpu | git push upstream |
  119. | gpv | git push -v |
  120. | gr | git remote |
  121. | gra | git remote add |
  122. | grb | git rebase |
  123. | grba | git rebase --abort |
  124. | grbc | git rebase --continue |
  125. | grbd | git rebase $(git_develop_branch) |
  126. | grbi | git rebase -i |
  127. | grbm | git rebase $(git_main_branch) |
  128. | grbom | git rebase origin/$(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. | gswm | git switch $(git_main_branch) |
  169. | gswd | git switch $(git_develop_branch) |
  170. | gts | git tag -s |
  171. | gtv | git tag \| sort -V |
  172. | gtl | gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl |
  173. | gunignore | git update-index --no-assume-unchanged |
  174. | gunwip | git log -n 1 \| grep -q -c "\-\-wip\-\-" && git reset HEAD~1 |
  175. | gup | git pull --rebase |
  176. | gupv | git pull --rebase -v |
  177. | gupa | git pull --rebase --autostash |
  178. | gupav | git pull --rebase --autostash -v |
  179. | glum | git pull upstream $(git_main_branch) |
  180. | gwch | git whatchanged -p --abbrev-commit --pretty=medium |
  181. | gwip | git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]" |
  182. | gam | git am |
  183. | gamc | git am --continue |
  184. | gams | git am --skip |
  185. | gama | git am --abort |
  186. | gamscp | git am --show-current-patch |
  187. ### Main branch preference
  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. ### Deprecated aliases
  193. These are aliases that have been removed, renamed, or otherwise modified in a way that may, or may not, receive further support.
  194. | Alias | Command | Modification |
  195. | :----- | :----------------------------------------------------- | :----------------------------------------------------- |
  196. | gap | `git add --patch` | new alias `gapa` |
  197. | gcl | `git config --list` | new alias `gcf` |
  198. | gdc | `git diff --cached` | new alias `gdca` |
  199. | gdt | `git difftool` | no replacement |
  200. | ggpull | `git pull origin $(current_branch)` | new alias `ggl` (`ggpull` still exists for now though) |
  201. | ggpur | `git pull --rebase origin $(current_branch)` | new alias `ggu` (`ggpur` still exists for now though) |
  202. | ggpush | `git push origin $(current_branch)` | new alias `ggp` (`ggpush` still exists for now though) |
  203. | gk | `gitk --all --branches` | now aliased to `gitk --all --branches` |
  204. | glg | `git log --stat --max-count = 10` | now aliased to `git log --stat --color` |
  205. | glgg | `git log --graph --max-count = 10` | now aliased to `git log --graph --color` |
  206. | gwc | `git whatchanged -p --abbrev-commit --pretty = medium` | new alias `gwch` |
  207. ## Functions
  208. ### Current
  209. | Command | Description |
  210. |:-----------------------|:---------------------------------------------------------------------------------------------------------|
  211. | `grename <old> <new>` | Rename `old` branch to `new`, including in origin remote |
  212. | current_branch | Return the name of the current branch |
  213. | git_current_user_name | Returns the `user.name` config value |
  214. | git_current_user_email | Returns the `user.email` config value |
  215. | git_main_branch | Returns the name of the main branch: `main` if it exists, `master` otherwise |
  216. | git_develop_branch | Returns the name of the develop branch: `dev`, `devel`, `development` if they exist, `develop` otherwise |
  217. ### Work in Progress (WIP)
  218. 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.
  219. | Command | Description |
  220. |:-----------------|:------------------------------------------------|
  221. | work_in_progress | Echoes a warning if the current branch is a wip |
  222. | gwip | Commit wip branch |
  223. | gunwip | Uncommit wip branch |
  224. ### Deprecated functions
  225. | Command | Description | Reason |
  226. |:-----------------------|:----------------------------------------|:----------------------------------------------------------------|
  227. | current_repository | Return the names of the current remotes | Didn't work properly. Use `git remote -v` instead (`grv` alias) |