Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim not working when calling git commit within cygwin

I am using git within Cygwin 64 under windows. The default editor vi and git uses the default editor. When I call 'git commit' following messages will be prompted before vim is started:

git commit Vim warning: output is not to a terminal Vim warning: input is not from a terminal 

After that, vi will started but can't be controlled, 'ESC', ':' can't be used and I have to kill the cygwin window.

enter image description here

How can I use vim for the 'git commit'?

like image 559
Christian Schulzendorff Avatar asked Apr 20 '16 11:04

Christian Schulzendorff


People also ask

Can I use Vim with Git?

Git command works in the command line interface. The vim plugin named fugitive plugin is developed by Tim pope which is used to work with the git tool without terminating the editor. So, vim and git can work together by using the fugitive plugin.


2 Answers

This might be cause by mintty, see this issue.

There are two ways to fix:

  1. Use bash.exe instead of mintty:

    Right click on the shortcut of cygwin, change it from C:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico - to C:\cygwin64\bin\bash.exe --login -i

  2. Add the correct vim path to git config:

    git config --global core.editor "C:/cygwin64/bin/vim.exe"

    Note that don't use cygdrive in the path as .gitconfig can't recognize it. And if you are using 32-bit vim, then the path should be C:/cygwin/bin/

like image 198
Deqing Avatar answered Oct 10 '22 02:10

Deqing


You may have Git for Windows (msysgit) or Vim for Windows installed. Out of the box they are not compatible with Cygwin64 - you would need to configure your pathing for Cygwin to ignore those installations.

The easier option would be to uninstall both of those items and just use the Cygwin version.

If you need to keep them for whatever reason, set your $PATH variable in your .bash_profile as an override. Use your existing $PATH, minus the msysgit and windows vim paths. If you're into bash scripting, you could try the following to remove the paths when using bash, modified to your particular situation:

msysgit='/cygdrive/c/Program Files/git:' PATH="${msysgit//$PATH/}" msysvim='/cygdrive/c/Program Files (x86)/vim/vim74:' PATH="${mysysvim//$PATH/}" 

Good luck!

like image 37
CYB.tachyon Avatar answered Oct 10 '22 00:10

CYB.tachyon