How to Change the Default Editor for Git [duplicate]

与世无争的帅哥 提交于 2020-01-31 02:39:11

问题


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:

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.

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?


回答1:


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:

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.




回答2:


Are you on a Mac ? If you run TextWrangler from the command line (Terminal.app) does TextWrangler open?

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).

Try changing core.editor to vim and see if you still get the error.

Also - check out this thread (it may help).




回答3:


Follow-up to @thornomad

Command for changing editor in Git is (one of possibilities)

git config --global core.editor "mate -w", there string inside quotes marks is full command-line for invoking editor from terminal



来源:https://stackoverflow.com/questions/13257519/how-to-change-the-default-editor-for-git

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!