Terminal – How to Set Xcode as Core Editor in Git

gitterminaltext-editorxcode

My current git config core.editor returns dreamweaver which I set up two years ago from inside the app(IIRC), and now I don't use it. I am receiving error while amending the author of the last commit.

~$ git commit --amend --author="me <my@mail>"
hint: Waiting for your editor to close the file... fatal: cannot run 
dreamweaver: No such file or directory
error: unable to start editor 'dreamweaver'

How do I set it to use Xcode? I tried

git config --global core.editor="xcode"
error: invalid key: core.editor=Xcode

And from https://stackoverflow.com/questions/53550025/git-unable-to-start-xcode-from-terminal-on-mac-os-x, even though xed launches Xcode.

$ git config --global core.editor="xed"
error: invalid key: core.editor=xed

xed -w also launches Xcode so I tried the same instead of ="xed -w" but same error.

Best Answer

It's all about syntax sometimes :-)

git config --global core.editor 'xed -w'

Not sure whether you really want to wait for Xcode to launch each time you git commit something. Maybe vi or nano are the better options here.