Is there a way to prevent git from opening a password prompt box on Windows?
Asked Answered
B

3

10

While pushing on a remote repository using git bash, my password is required and asked. This is not a problem.

The issue is that I was used to just type my password into the git console, but then I switched from Linux to Windows and my password is asked into a prompt box instead of the console.

Prompt box for password

I find it much less convenient: I have to wait for one second that it appears and sometimes I lose the focus.

What is strange is that if I close the dialog box, then the password is asked from within the git console. This is what I am looking for.

What I am looking for

Do you know how could I prevent the box to be prompted and just let me type my password into the console, please? Is there some git option I should modify?

Boredom answered 20/1, 2016 at 17:17 Comment(4)
If you notice, the error message in your console says "error: unable to read askpass response from C:\Program Files\Git\mingw64\libexec\git-core\git-gui--askpass" - this UI addition seems to be the thing causing the dialog prompt, not git itself.Stubborn
@Chris Thank you, I noticed it but I did not know what to do with it. I am looking to the git-config options to see if there is a way to set the default behavior.Boredom
This has nothing to do with git itself, but the installation clearly has problems. How did you install it? I've installed Git using Chocolatey, Github and TortoiseGit but I didn't encounter such a problem. Have you tried to do a push from the command line? You can avoid this entirely by using a credential helper like Git's own wincred or Microsoft's Git credential managerBillfold
@PanagiotisKanavos From the command line it worked without prompt box. I just made a fresh install: I downloaded git from official website and I followed instructions by checking the options I wanted p1, p2, p3 (I tried both), p4, p5.Boredom
B
13

This seems to be related with the core.askPass option of git-config.

The documentation says:

core.askPass
Some commands (e.g. svn and http interfaces) that interactively ask for a password can be told to use an external program given via the value of this variable. Can be overridden by the GIT_ASKPASS environment variable. If not set, fall back to the value of the SSH_ASKPASS environment variable or, failing that, a simple password prompt. The external program shall be given a suitable prompt as command-line argument and write the password on its STDOUT.


My default configuration contains nothing about this option, so I guess it fall back to the "simple password prompt".

To override this behavior, I just had to set the option to an empty string:

git config --global core.askPass ''

Then, the password is asked from the console without prompting anything.

Boredom answered 20/1, 2016 at 18:37 Comment(0)
U
1

In 2022 (6 years later), you can install the latest GCM 2.0.692 (Git Credential Manager).
And use it with:

  • git config --global credential.helper manager-core
  • git config --global credential.guiPrompt false
  • or: SET GCM_GUI_PROMPT=0

That will disable any prompt and leave the user only with a terminal prompt only.

Usury answered 2/4, 2022 at 21:37 Comment(1)
Gold worth, this answer it isPapain
B
0

If you are pushing code to a repository you usually work with, I recommend you to authenticate yourself using your public key instead of your password. If you do so, you will not be asked for the password over and over, neither in the console nor in a prompt

Battue answered 20/1, 2016 at 17:29 Comment(1)
Thank you for the tip but this does not actually answer my question, I feel it just bypass the problem without really fixing it.Boredom

© 2022 - 2024 — McMap. All rights reserved.