21

I changed my Github account recently. I have my new username and email stored in global .gitconfig:

[filter "lfs"]
    process = git-lfs filter-process
    required = true
    clean = git-lfs clean -- %f
    smudge = git-lfs smudge -- %f
[user]
    name = myusername
    email = myemail@gmail.com
[credential]
    helper = store
    username = myusername

and my password for github in .git-credentials.

Every time I push to my remote repository Github login pops up asking me for my credentials.

Github login popup

And when I cancel it everything works fine. I don't need to enter username or password. Remote is updated. How to get rid of that popup? I didn't have that behaviour before changing account credentials.

Denis B
  • 235
  • 1
  • 2
  • 9
  • As of 2022, `guiPrompt = false` property worked for me: https://stackoverflow.com/a/73137673/7505906 – Pepo48 Jul 27 '22 at 12:13

3 Answers3

25

Git has the concept of multiple credential managers. When you installed Git for Windows, it came with the Git Credential Manager for Windows (either the old one or Core), and you probably answered a question about whether you wanted to use it or not.

Somewhere in an earlier config file, such as the system one, there's a setting that looks like credential.helper = manager. Because Git invokes the credential managers in order and uses the first one that provides it credentials, it first asks the manager one specified at the system level, causing the pop-up, and then invokes the store one in your local config file.

What likely happened is that your old account was using the manager helper but the new one is using the store helper for saving your password, so the prompt didn't show up for manager because it had your credentials saved.

If you don't find the manager helper, run git config -l --show-origin to find the file which has the other credential.helper setting and then edit it to remove that option.

Do note that the manager helper is going to be more secure than storing your credentials in a file on disk (since it will be encrypted), and it will use a personal access token, which GitHub will require in the future, so you may want to use the popup prompt to get credentials and remove the store helper instead.

isherwood
  • 58,414
  • 16
  • 114
  • 157
bk2204
  • 64,793
  • 6
  • 84
  • 100
  • I have removed `manager` setting as you proposed and it worked. – Denis B Dec 27 '20 at 18:20
  • 1
    But if I remove `store` option, as you recommended, I stil get popup every time I try to `git push` and it doesn't connect now, but asks me in command line for password, and then connects. – Denis B Dec 27 '20 at 18:33
  • 1
    I have updated Git for Windows and it created a new entry in Credential Manager in Windows (which I must have deleted when changing credentials) and now everything works perfectly. And in the way you recommended for security reasons. Thank you very much. – Denis B Dec 27 '20 at 19:15
  • I tried this a while ago because I kept getting a pop up, but now I want to revert it, which file should I mess with? (and what do I add?) – JLMF Jun 23 '21 at 03:51
  • If you want to re-add a credential helper, you can add one in `~/.gitconfig`. That would be the `.gitconfig` file in your home directory. – bk2204 Jun 23 '21 at 17:31
3

I got this same problem today, got an email from Github that the way I accessed the git has been deprecated, so solved it as below:

  1. uninstall the git software ( Or, using Run > appwiz.cpl )

  2. install new git from here - https://git-scm.com/downloads

  3. for one time save password - run the below command for this project:

    git config --global credential.helper store

  4. now run below:

    git pull

Note:

  1. To run the 3rd & 4th command, you should already be in a git folder (where you ran the git clone https://github.com/../...git command)

  2. This issue occurred because now the GitHub changed it's authentication:
    from git credential manager
    to git credential manager core
    See below for more information

Basic authentication using a password to Git is deprecated and will soon no longer work. Visit https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/

Manohar Reddy Poreddy
  • 25,399
  • 9
  • 157
  • 140
0

This issue mainly occur when you try to push from VScode integrated terminal

Try pushing the commits directly from git bash or run these command just after you open VScode

git remote set-url origin  <repo-link>



git remote set-url origin https://<your github username>:<your password>@github.com/<your github username>/<your github repository name>.git

the last command saves your credentials for that particular session and wont ask again until you close and reopen VScode

iceweasel
  • 756
  • 1
  • 6
  • 11