Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set default editor when using Git in Cygwin?

Tags:

git

cygwin

I am using the Git CLI in Cygwin on Win7. I have a problem when I issue a command that requires editor interaction, such as

git commit --amend

In Cygwin, the command simply hangs and I must do Ctrl-Z to get the next prompt. The commit does not go through.

I tried to set the default editor to vi:

git config --global core.editor "vi"

But that did not work.

In Windows Terminal (DOS-like CLI), it redirects to a vi-like editor fine, i.e. business as usual. But it doesn't work in Cygwin. I prefer using Cygwin over Terminal because I was having some other issues in Terminal (wasn't showing which remotes the locals are tracking etc.)

How do I set the default editor when using Git on Cygwin?

like image 677
amphibient Avatar asked Nov 19 '14 17:11

amphibient


People also ask

How do I change the default editor in git?

The command to do this is git config --global core. editor "nano" . You can change the highlighted section with your editor of choice!

Which editor should I use for git?

Yes, Git uses Vim as its editor while committing your changes. Show activity on this post. Doing so launches your editor of choice. (This is set by your shell's $EDITOR environment variable – usually vim or emacs, although you can configure it with whatever you want using the git config --global core.


1 Answers

As per this answer, I did the following:

git config --global core.editor "D:/homex/SFTWR/cygwin/bin/vi.exe"

D:/homex/SFTWR/cygwin is the location of my Cygwin install. I am still perplexed why it is taking a Windows path when it's running in the Cygwin shell.

like image 186
amphibient Avatar answered Oct 31 '22 05:10

amphibient