LoginSignup
126
98

More than 5 years have passed since last update.

よく使うgitコマンドのエイリアスを設定して開発効率をアップする

Last updated at Posted at 2016-04-13

gitコマンドを打つのがダルかったりtypoしまくるので、よく使うコマンドのエイリアス(ショートカット)を設定して開発速度を若干上げる。

エイリアスの設定

git config [option] alias.短縮形 展開形 でエイリアスを設定する。

例えば以下のような感じ

$ git config --global alias.st status
$ git config --global alias.co checkout
$ git config --global alias.br branch
$ git config --global alias.cm commit
$ git config --global alias.df diff
$ git config --global alias.gr grep

これで git statusgit st でいけたりする。

設定レベル

オプションで設定レベル(適用範囲)を指定できる。

設定オプション 適用範囲 設定レベル
オプションなし リポジトリ固有 3
--global Gitユーザー固有 2
--system マシン全体 1

優先度は、リポジトリ > ユーザー > マシン

gitコマンドも省略する

もはやgitって打つのもダルくね?
$ alias g='git'
これで git statusg st でいける。

オプション含めてもっと短くもできるので好きにカスタマイズしよう。

設定の確認方法

エイリアスなに設定したか忘れたら
$ git config --global --list | grep ^alias\.
で確認しよう。

参考

126
98
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
126
98