Rya*_*ase 5 git text-editor sublimetext3
Despite similar questions that have been posted in the community, I have not seen this specific question addressed.
I am trying to change the default text editor used by git to Sublime. I am using a Windows machine and downloaded Sublime 3.
Initially, I was running the command git config --global core.editor "'C:\\Program Files\\Sublime Text 3\\sublime_text.exe' -n -w" in Git Bash, then when I ran a git commit it did not open an editor (it just used the Git Bash "editor").
However, when I add the flag -m to my git config: --global core.editor "'C:\\Program Files\\Sublime Text 3\\sublime_text.exe' -n -w -m" and run Git commit it now opens up the Notepad editor.
Note I have not changed any of the path or default text editor settings in Windows, I am only trying to have Sublime open up when running git commands.
尝试这个:
git config --global core.editor "'c:/program files/sublime text 3/subl.exe' -w"
这对我git commit有用(即,执行打开的Sublime Text窗口后,我可以在其中键入提交消息,保存并关闭该窗口后,我检查此提交是否包含我刚刚输入的提交消息git show)。在Windows 10上使用Git for Windows 2.10.2和Sublime Text 3 build 3126
请注意,subl.exe2014年8月27日在Build 3065中引入了Windows命令行帮助程序,因此该方法适用于#3065及之后的任何版本:
OP为响应第一条评论而发布的输出清楚地表明了问题所在:
命令:
git config --list --show-origin | grep -i core.editor
file:C:/Users/ryanj/.gitconfig core.editor='c:/program files/sublime text 3/subl.exe' -w
file:.git/config core.editor=notepad
Run Code Online (Sandbox Code Playgroud)
OP有一个用于core.editor记事本的存储库级别配置,它会覆盖设置为他期望的全局配置(即Sublime Text 3)。
要解决此问题,请运行以下命令:
git config --unset core.editor
Run Code Online (Sandbox Code Playgroud)
并确认git config --list --show-origin | grep -i core.editor仅显示一个配置文件(即c:/users/ryanj/.gitconfig),并将Sublime Text 3设置为编辑器。