30

In git bash for windows, the username and/or password is asked in a separate UI popup prompt like below.

Username Prompt

On Hitting Cancel you get the below shell based prompt, where the same username can be input.

Shell based username prompt

Is there a way I can disable these prompts? I still do want to enter my username and password however instead of the UI based prompt, i want to enter it through the shell based prompt.

Using suggestions from this does not help. How to undo git config --system core.askpass git-gui--askpass

Community
  • 1
  • 1
Yogesh_D
  • 17,656
  • 10
  • 41
  • 55
  • Possible duplicate of [How to undo git config --system core.askpass git-gui--askpass](http://stackoverflow.com/questions/30359035/how-to-undo-git-config-system-core-askpass-git-gui-askpass) – SiHa Dec 21 '15 at 13:15
  • using unset doesnt help. – Yogesh_D Dec 22 '15 at 06:51

6 Answers6

43

Try to set the variable core.askPass globally (in your config-file)

$ git config --global core.askPass true

or use the -c switch to override it just for one command

$ git -c core.askPass=true clone <https_url>

see: https://git-scm.com/docs/gitcredentials

If a helper outputs a quit attribute with a value of true or 1, no further helpers will be consulted, nor will the user be prompted (if no credential has been provided, the operation will then fail).

Note: un-setting the core.askPass by using git config --global --unset core.askPass doesn't help. It needs to be set to an true like above.

Update 2021-10-22:

The original answer proposed setting empty string "", but at least on Ubuntu this does not work and the docs also describe that the helper should output true or 1.

angularsen
  • 8,160
  • 1
  • 69
  • 83
hinneLinks
  • 3,673
  • 26
  • 40
  • tried to use this { git config --global --unset core.askPass } and then { git clone https://example.com:/url } but then no prompt for password and get this error { fatal: could not create work tree dir 'repo': Permission denied } – Yogesh_D Dec 21 '15 at 13:49
  • do you have sufficient rights to create a dir `repo` in a normal terminal? Maybe it already exists from your previous attempts? – hinneLinks Dec 21 '15 at 13:55
  • Yup.. On a Windows desktop and no permission issues.. When I unset the core.askPass I don't get any prompt at all for the password.. I believe that is the cause of the permission issues – Yogesh_D Dec 21 '15 at 14:48
  • 1
    try `git config --global core.askPass true`. If thats not working you could try an invalid command (e.g. `git config --global core.askPass invalid-foo`. – hinneLinks Dec 21 '15 at 20:03
  • taking your idea further these settings help, either use 1. git config --global core.askPass "" or 2. git -c core.askPass="" clone . Setting it to an empty string gives me prompts at the shell like i wanted. Editing your answer to put these in and accepting it. – Yogesh_D Dec 22 '15 at 06:55
  • Is there a generic solution applicable to all repositories ? I have Git BASH/MINGW64 and using bower to clone/pull a repo. – Rohit V Mar 30 '16 at 16:54
  • `git config --global core.askPass true` worked on Ubuntu here, while setting empty string `""` as in the answer still prompted me for password. – angularsen Oct 22 '21 at 08:34
  • `git config --global core.askPass true` failed for me on windows. Resulted in no dialog window and no command line prompt either. The `git pull` command hangs forever with no prompt. (The main git repo is an ssh key with no password, but the git-lfs repo is https and requires a password) – cowlinator Nov 19 '21 at 02:58
2

Use ssh instead of http/https.

You will need to set ssh keys on your local machine, upload them to your git server and replace the url form http:// to git:// and you will not need to use passwords anymore.

If you cant use ssh add this to your config:

[credential "https://example.com"]
    username = me

documents are here.

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • 2
    ssh-keys are currently not an option. I specifically need to disable this for userid/pwd over https – Yogesh_D Dec 21 '15 at 13:43
1

You may try the configuration below:

git config --global --unset credential.helper

and

git config --system --unset credential.helper

This helped me while I am using PortableGit 64-bit 2.12.1.1 on Windows 7.

Jason Tian
  • 23
  • 6
1

As of 2022, I ended up with using following properties in .gitconfig:

[credential]
  guiPrompt = false
  gitHubAuthModes = basic #in case of the basic (username/password) authentication
Pepo48
  • 21
  • 1
0

Unset SSH_ASKPASS.

unset SSH_ASKPASS

To do this automatically each time you open git bash, you can add the above line to the end of your .bashrc.

Investigation

The gitcredentials docs linked in other answers list a number of places git will check to determine how to ask for a password. I investigated each in turn:

env | grep GIT
git config --get core.askPass
env | grep SSH

The last command told me SSH_ASKPASS existed:

SSH_ASKPASS=/mingw64/libexec/git-core/git-gui--askpass`.

This is not part of my dotfiles, and so seems to come from the default Windows git distribution from http://git-scm.com.

Alex Palmer
  • 1,189
  • 9
  • 9
  • 1
    I had to add this to .profile It looks like my version of git bash sets up the SSH_ASKPASS in /etc/profile.d/env.sh and my ~/.profile does not source my ~/.bashrc (which had I had already _unset SSH_ASKPASS_ a while back) – Tim Lum Jun 13 '16 at 19:11
  • This simply unsets the askpass, and works only if there are no submodules in the repo, if the password is asked for multiple times then the submodules will fail on a `git clone --recursive` – rivanov Sep 11 '17 at 19:50
  • @rivanov That's interesting. `unset SSH_ASKPASS` should make git exclusively its built-in password mechanism on the CLI. If it fails when you do this, how does git normally handle submodules with `git clone --recursive`? – Alex Palmer Sep 14 '17 at 13:31
0

In my case I've been using git 1.9.5 for 3 years. And recently I tried to install latest version 2.15.0. In the latest git bash when I do git pull it was asking me to enter password whereas in old git version(1.9.5) it won't ask anything like that.

I did search in google. Finally my friend helped me to resolve that. It is because I've configured dsa key instead of rsa key. As per my understanding dsa is old key format and rsa is new key format.

To use the latest git bash with old dsa key I did the below thing, create a file named "config"(It is the full name) inside your .ssh folder. In that file give the below note,

PubkeyAcceptedKeyTypes=+ssh-dss

And save it.

Now open the latest git bash. And do git pull. It won't ask any password and just pull the commits.