🖥

git / gitconfig alias / use command argument

2020/01/01に公開

.gitconfig

  • Define temporary function. in this example "f"
  • Will called soon temporary function without any args. because implicit used git command args.
  • You can define same temporary function name like "f" multiple times. it will be not conflicted.
[alias]
  checkout-and-say-hello = "!f() { git checkout \"$1\" && echo Hello; }; f"
  checkout-and-say-wow = "!f() { git checkout \"$1\" && echo Wow; }; f"

Run

$ git checkout-and-say-wow master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
Wow
$ git checkout-and-say-hello master
Already on 'master'
Your branch is up to date with 'origin/master'.
Hello

Ref

command - Git alias with positional parameters - Stack Overflow
https://stackoverflow.com/questions/3321492/git-alias-with-positional-parameters

Original by Github issue

https://github.com/YumaInaura/YumaInaura/issues/2898

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ

Twitter

https://twitter.com/YumaInaura

公開日時

2020-01-01

Discussion