Cygwin/Git Bizarre Terminal Issue

cygwin;gitminttyzsh

Alright, this is weird. First off, this is mintty running on up-to-date cygwin, with git pulled from cygwin's setup.exe. I am running zsh.

$ git clone https://<user>@<domain>/<repository>/ ~/src/project/dev
Initialized empty Git repository in /cygdrive/c/src/project/dev/.git/
Password: <actual password in plain text appears>
# Nothing happens...
^C
$ <password text that I just typed>
zsh: command not found: <same password text>

What is going on here? Is this a terminal problem, a shell problem, a git problem, or a cygwin problem?

Update: Yes, I'm running the Cygwin git version, not the Windows version:

$ which git
/usr/bin/git
$ git --version
git version 1.7.1
$ /cygdrive/c/Program\ Files\ \(x86\)/Git/bin/git.exe --version
git version 1.7.0.2.msysgit.0

Best Answer

OK, I think I've found a definite solution.

The problem is that, regardless of the terminal used (puttycyg, mintty, cmd.exe), Git by default, in the absence of better configured alternatives, tries to use a "simple password prompt" (as you can read in the description of core.askpass config option).

The simple password prompt apparently only works on real UNIX, but not on Cygwin.

The solution is to install an SSH_ASKPASS compatible program for Windows and configure Git to use it.

What I did was:

  1. Install win-ssh-askpass application by unpacking and copying to C:\
  2. Download and install the Borland Delphi 5 runtime required by win-ssh-askpass (hard to come by nowadays, but found one on http://www.satsignal.eu/software/runtime.html)
  3. Configure Git to obtain passwords using win-ssh-askpass: git config --global core.askpass "C:/win_ssh_askpass.exe". Note that the EXE file has underscores in its name, not minus signs.
  4. Remember to always place your login in the URL (https://<user>@<domain>/<repository>). Otherwise, Git will ask for the login before asking for the password, using the same askpass utility. You may unknowingly input your password as the login, which will be sent to the webserwer and logged in its access log as plain text!

Now Git asks for the password using an elegant GUI window and works regardless of the terminal used :)

Related Question