简体   繁体   中英

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

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.

密码提示框

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.

我在找什么

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?

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

The documentation says:

core.askPass
Some commands (eg 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.

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM