15
5

More than 1 year has passed since last update.

Gitで使用するエディターを変更する

Posted at

git commit 時のエディターを変更する

$ git config --global core.editor <エディタ名>

git rebase -i 時のエディターを変更する

$ git config --global sequence.editor <エディタ名>

※指定しない場合は core.editor が使われます。
ので、使い分けしたいとかなければ設定不要です。

お好みのエディタを設定する

お好みなのでなんでも良いです。よく目にするエディタを抜粋しました。

# Emacs
$ git config --global core.editor emacs
$ git config --global sequence.editor emacs

# Nano
$ git config --global core.editor nano
$ git config --global sequence.editor nano

# Helix
$ git config --global core.editor hx
$ git config --global sequence.editor hx

# micro
$ git config --global core.editor micro
$ git config --global sequence.editor micro

# Visual Studio Code
$ git config --global core.editor 'code --wait'
$ git config --global sequence.editor 'code --wait'

VSCode(GUIエディタ)で編集する時は --wait オプションを付けて保存してファイルが閉じるまで待ってくれるオプションを指定します。
Vimに戻したい時はこちら

$ git config --global core.editor vim
$ git config --global sequence.editor vim

Git Interactive Rebase Tool

$ git config --global sequence.editor interactive-rebase-tool

最近見つけたツールで試しに使ってみてます。
rebase用とエディタを分けれるのでこういう時に sequence.editor があると便利かもです。

参考

https://git-scm.com/book/ja/v2/Git-%E3%81%AE%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%9E%E3%82%A4%E3%82%BA-Git-%E3%81%AE%E8%A8%AD%E5%AE%9A
https://qiita.com/takeo-asai/items/9bc7e25cd94cd8c9adee

15
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
15
5