如何更改 Git 的默认编辑器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13257519/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to Change the Default Editor for Git
提问by jac300
I just started using git about a month ago. It was set up for me using TextMate as my default editor for commits. However, I'd like to switch the default to TextWrangler which I already have installed. I looked around online and found a line of code to type into the terminal to do this. So I opened the terminal and typed:
我大约一个月前才开始使用 git。它是为我设置的,使用 TextMate 作为我的默认提交编辑器。但是,我想将默认设置切换为我已经安装的 TextWrangler。我在网上环顾四周,发现一行代码可以在终端中输入以执行此操作。所以我打开终端并输入:
cd Desktop
cd "projectName"
git config --global core.editor TextWrangler
git status
git add.
git commit //then the error comes up
The error says: error: cannot run TextWrangler: No such file or directory error: There was a problem with the editor 'TextWrangler'. Please supply the message using either -m or -F option.
错误说:错误:无法运行 TextWrangler:没有这样的文件或目录错误:编辑器“TextWrangler”出现问题。请使用 -m 或 -F 选项提供消息。
I don't know what this means or what I am doing wrong. I am sure its an obvious mistake, but can anyone explain how to fix this?
我不知道这意味着什么或我做错了什么。我确定这是一个明显的错误,但谁能解释一下如何解决这个问题?
回答by jac300
Just answered my own question with the help of the above comments... to switch to TextWrangler as the default for Git, you must open TextWrangler, click on TextWrangler in the tool bar and select "install command line tools" from the drop down. Then go into command line and type:
刚刚在上述评论的帮助下回答了我自己的问题……要切换到 TextWrangler 作为 Git 的默认设置,您必须打开 TextWrangler,单击工具栏中的 TextWrangler,然后从下拉列表中选择“安装命令行工具”。然后进入命令行并输入:
git config --global core.editor "edit -w"
Edit is the command that is understood in the command line which means to open a textWrangler file.
Edit 是命令行中理解的命令,意思是打开 textWrangler 文件。
回答by thornomad
Are you on a Mac ? If you run TextWrangler
from the command line (Terminal.app) does TextWrangler open?
你在 Mac 上吗?如果您TextWrangler
从命令行 (Terminal.app)运行,TextWrangler 会打开吗?
My guess is that git is expecting you to pass it the name of an executable that is in your PATH
... I would also guess that TextWrangler is not (this is just a guess, no experience with it).
我的猜测是 git 期望您将您的可执行文件的名称传递给它PATH
......我也猜测 TextWrangler 不是(这只是猜测,没有经验)。
Try changing core.editor
to vim
and see if you still get the error.
尝试更改core.editor
为vim
,看看是否仍然出现错误。
Also - check out this thread(it may help).
另外 - 看看这个线程(它可能有帮助)。
回答by Lazy Badger
Follow-up to @thornomad
跟进@thornomad
Command for changing editor in Git is (one of possibilities)
在 Git 中更改编辑器的命令是(一种可能性)
git config --global core.editor "mate -w"
, there string inside quotes marks is full command-linefor invoking editor from terminal
git config --global core.editor "mate -w"
,引号内的字符串是用于从终端调用编辑器的完整命令行