LoginSignup
1
0

More than 1 year has passed since last update.

【Git】Gitエイリアスの使用

Posted at

はじめ

  最近、gitのドキュメントを読んでいます。
  今後の復習のため、ポイントをメモしました。

2.7 Gitエイリアス gitのドキュメント

Gitは、コマンドの一部だけが入力された状態でそのコマンドを自動的に推測することはない。「git config」でコマンドのエイリアスを設定することができる。
例えば↓

$ git config --global alias.co checkout

こうすると、git checkoutと同じことが単にgit coと入力するだけでできるようになる。

新しいコマンドを作成することはできる。(Gitが新しいコマンドをエイリアスで置き換えている)↓
例えば、ステージを解除するコマンド

$ git config --global alias.unstage 'reset HEAD --'

下記のコマンドが同じ意味となる

$ git unstage fileA
$ git reset HEAD --fileA

Gitのサブコマンドではなく外部コマンドを実行することもできる。
コマンドの先頭に!をつける。
例えば、git visualでgitkが起動する。↓

$ git config --global alias.visual '!gitk'
1
0
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
1
0