26

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'?

6
  • 1
    Changing the default editor can be a good alternative solution : git config core.editor notepad Commented Apr 20, 2016 at 14:25
  • 1
    Are you sure to not have another VI on the path ? The last row of your screenshot is strange D:/.. Commented Apr 21, 2016 at 20:01
  • What happens if you try: TERM=xterm git commit Commented Apr 21, 2016 at 21:54
  • @ Acemad: I want to use vim or vi, not notepad. Commented Apr 23, 2016 at 9:47
  • @matzeri: The behavior of the cygwin session after git commit is unregulated. The bash screen will not be cleaned from the vim output and I have to kill the session. Commented Apr 23, 2016 at 9:53

5 Answers 5

18

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/

Sign up to request clarification or add additional context in comments.

2 Comments

This should be the best and accepted answer. Point 2 works for me without any problem so far. (Pros: able to keep using mintty, and using Windows native installed git binary)
Finally! Took me far too long to find this. Works perfectly.
10

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!

2 Comments

This worked for me, with the exception that the second line(string replacement) seems incorrect, the following line worked instead: PATH="${PATH//$msysgit/}" Also you have to use the proper current pathname to git in your system, which for me was msysgit='/cygdrive/c/Program Files/Git/cmd:'
This is no solution as cygwin's git has issues. The proper solution is provided by Deqing.
4

You have the windows version of GIT installed rather than the CYGWIN version of GIT installed. GIT by default comes with a full set of UNIX tools including its own version of VI. Unfortunately, that version of VI does not play nice with CYGWIN. The best way around this is to install GIT in CYGWIN so that it will use the CYGWIN version of VI or VIM.

1 Comment

I had exactly this problem and installing Git from the Cygwin installer did the trick for me.This answer should be the accepted answer as it is the easier way to solve the problem.
0

I faced this same issue. @CYB.tachyon and @David Beckman both explained WHY vim id breaking; but, rather than uninstalling anything, I ran my git command from a DOS-style command prompt and all went smoothly. I suppose - eventually - cleaning up the various flavors of vim will be MY ultimate solution, but if you just want to get on with your work, this was the quickest solution to the immediate problem.

Comments

-1

When you install Git for Windows, you MUST choose Use Git from Git Bash Only.

Use Git from Git Bash Only

If you choose Use Git from the Windows Command Prompt, it will cause this issue.

And honestly, who's going to use git from the command prompt? ;)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.