LoginSignup
6
5

More than 5 years have passed since last update.

gitconfigで何のエイリアスを設定していたかを確認するエイリアス

Last updated at Posted at 2016-02-16

「あれいいな」、「これいいな」とgitconfigにエイリアスをあれこれ設定していくと、「あれ、なんのエイリアス設定していたっけ?」ってなることがたまにあります。
そうなった時に、

less ~/.gitconfig

として見に行くのも手なのですが、せっかくなのでエイリアスを確認するエイリアスを用意します。笑

エイリアスを設定する

.gitconfigを開いて、[alias]の項目に、以下を追加します。

aliases = !git config --get-regexp alias | grep -v aliases | sed 's/^alias.//g' | sed 's/ / = /1' | sort

コマンドラインから追加するばあいは、

globalに設定するばあいは--globalを付け忘れずに!
git config --global alias.aliases "\!git config --get-regexp alias | grep -v aliases | sed 's/^alias.//g' | sed 's/ / = /1 | sort'"

とします。

これで、

git aliases

と入力したときに、

co = checkout
pu = push
st = status -sb

のように表示することができます。
設定しておいても損はないので是非!

ちなみに

output
!git config --get-regexp alias

でもエイリアスの表示としては十分なのですが、

output
alias.co checkout
alias.st status -sb
alias.pu push

といった感じで"alias."が付くのと、どこからが実部分なのか分かりづらいので、若干整形しています。

6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5