Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| git_aliases [2019/02/17 14:06] – [Setting and listing aliases] rpjday | git_aliases [2019/02/25 13:15] (current) – [How to set a shell-style Git alias] rpjday | ||
|---|---|---|---|
| Line 6: | Line 6: | ||
| * [[https:// | * [[https:// | ||
| + | * [[https:// | ||
| ===== Setting and listing aliases ===== | ===== Setting and listing aliases ===== | ||
| + | |||
| + | ==== Setting regular Git aliases ==== | ||
| How to set a //regular// Git alias (note the need for quotes with multi-word values): | How to set a //regular// Git alias (note the need for quotes with multi-word values): | ||
| Line 26: | Line 29: | ||
| $ git cb newbranch | $ git cb newbranch | ||
| </ | </ | ||
| + | |||
| + | ==== Recursive Git aliases ==== | ||
| You can also define Git aliases in terms of other Git aliases: | You can also define Git aliases in terms of other Git aliases: | ||
| Line 31: | Line 36: | ||
| < | < | ||
| $ git config --global alias.bl blame | $ git config --global alias.bl blame | ||
| - | $ git config --global alias.blm 'bl Makefile" | + | $ git config --global alias.bm 'bl Makefile" |
| </ | </ | ||
| - | after which: | + | after which you could run the equivalent of '' |
| < | < | ||
| - | $ git fp | + | $ git bm |
| </ | </ | ||
| + | ==== Aliases in the .gitconfig file ==== | ||
| + | What ends up in your '' | ||
| + | |||
| + | < | ||
| + | ... | ||
| + | [alias] | ||
| + | a = add | ||
| + | cm = commit | ||
| + | co = checkout | ||
| + | b = blame | ||
| + | cb = checkout -b | ||
| + | bm = b Makefile | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | ===== How to unset Git aliases ===== | ||
| + | |||
| + | < | ||
| + | $ git config --global --unset alias.blm | ||
| + | </ | ||
| + | |||
| + | or just edit the '' | ||
| ===== How to set a shell-style Git alias ===== | ===== How to set a shell-style Git alias ===== | ||
| Line 45: | Line 72: | ||
| $ git alias bu "!git rev-parse --abbrev-ref --symbolic-full-name " | $ git alias bu "!git rev-parse --abbrev-ref --symbolic-full-name " | ||
| </ | </ | ||
| + | |||
| + | The shell command being run does not have to be '' | ||