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

查看:484
本文介绍了如何使Git使用我选择的编辑器进行提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我如何将Git配置为始终使用Vim?请注意,我想在全球范围内执行此操作,而不仅限于单个项目。

解决方案

如果要设置编辑器>只有为Git,做(你不需要这两个):








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

  export VISUAL = vim 
export EDITOR =$ VISUAL

*设置不一定是必需的,但是一些程序可能不会使用更正确的 VISUAL 。请参阅 VISUAL vs. EDITOR






对于升华文本
将其添加到 .gitconfig 中。 - 等待很重要。 (它允许在升华中键入文本,并等待保存/关闭事件。

  [core] 
editor = 'subl' - 等待

'subl'可以被完整路径替换可执行,但通常在正确安装时可用。



PS>对于使用subl即Sublime Text,请确保 Subl已正确安装并设置


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

How do I configure Git to always use Vim? Note that I want to do this globally, not just for a single project.

解决方案

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

  • Set core.editor in your Git config: git config --global core.editor "vim"
  • Set the GIT_EDITOR environment variable: 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*:

export VISUAL=vim
export EDITOR="$VISUAL"

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


For Sublime Text: Add this to the .gitconfig. The --wait is important. (it allows to type text in sublime and will wait for save/close event.

[core]
    editor = 'subl' --wait

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

P.S> For using subl i.e. Sublime Text, make sure Subl is installed and set up properly.

这篇关于如何使Git使用我选择的编辑器进行提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆