Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
347 views
in Technique[技术] by (71.8m points)

git - 如何使Git使用我选择的编辑器进行提交?(How do I make Git use the editor of my choice for commits?)

I would prefer to write my commit messages in Vim, but it is opening them in Emacs.

(我更愿意在Vim中编写我的提交消息,但是它正在Emacs中打开它们。)

How do I configure Git to always use Vim?

(如何配置Git始终使用Vim?)

Note that I want to do this globally, not just for a single project.

(请注意,我要全局执行此操作,而不仅仅是针对单个项目。)

  ask by brasskazoo translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you want to set the editor only for Git, do either (you don't need both):

(如果要设置对Git的编辑器,你要么(你不需要两者):)

  • Set core.editor in your Git config: git config --global core.editor "vim"

    (在您的Git配置中设置core.editorgit config --global core.editor "vim")

  • Set the GIT_EDITOR environment variable: export GIT_EDITOR=vim

    (设置GIT_EDITOR环境变量: export GIT_EDITOR=vim)


If you want to set the editor for Git and also other programs , set the standardized VISUAL and EDITOR environment variables*:

(如果要为Git 和其他程序设置编辑器,请设置标准化的VISUALEDITOR环境变量*:)

export VISUAL=vim
export EDITOR="$VISUAL"

* Setting both is not necessarily needed, but some programs may not use the more-correct VISUAL .

(*不必同时设置两者,但是某些程序可能未使用更正确的VISUAL)

See VISUAL vs. EDITOR .

(参见VISUAL vs. EDITOR)


For Sublime Text : Add this to the .gitconfig .

(对于Sublime Text :将其添加到.gitconfig 。)

The --wait is important (it allows to type text in sublime and will wait for save/close event.)

(--wait很重要(它允许在sublime中键入文本,并将等待保存/关闭事件。))

[core]
    editor = 'subl' --wait

'subl' can be replaced by the full path of the executable but is usually available when correctly installed.

(可以用可执行文件的完整路径替换“ subl”,但通常在正确安装后才可用。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...