26

Where I work many people use the same computer on the same account. We now use the shell instead of the GUI just for convenience.

The first time someone committed it asked for their username and password, but after that just used their account for all commits. I'm sorry that I don't know much about the shell, but this is the first time I'm using it. The commands I use to commit and synchronize are:

git commit -a
git push origin [branch name here]
Amit Joshi
  • 15,448
  • 21
  • 77
  • 141
Joshua Johnson
  • 363
  • 1
  • 3
  • 4

3 Answers3

38

If you use a Windows system, the Git username and password is stored in a control panel. You can go to Control PanelUser AccountsCredential Manager:Generic Credentials to delete it.

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
haiwuxing
  • 1,162
  • 10
  • 12
  • 4
    You are god to me. I spent 4 entire hours looking for this. I had to deploy and now I am delayed but i will worship you forever. I uninstalled and reinstalled git 30 times. YOU ARE GOD!!! – ICanKindOfCode Jan 27 '18 at 16:06
  • I have git credentials in my keychain for which is same for most of my clients projects , but i have to use different account in same site , i.e. both users are in github only , so by default it takes the credentials of my work keychain , how could i stop it and i can use my other credentials in my other projects – Shreyan Mehta Jul 23 '19 at 11:36
8

It seems that users credentials are being cached.

Go to your project, open .git/config and remove the lines:

[credential]
    helper = store
    # or helper=cache

Check git-credential-store for more information.

Edit: OP mentions in the comments that this is happening in Windows, for which, the other answer is more relevant for removing the credentials from the Control Panel.

Anshul Goyal
  • 73,278
  • 37
  • 149
  • 186
  • Where can I find this file? I can't find it in my project and the only thing related i could find was .gitconfig. – Joshua Johnson Sep 10 '14 at 03:23
  • @JoshuaJohnson the password must have been saved in one of `~/.netrc` or `~/.git-credentials`. And these settings must be present in `~/.gitconfig` or `$PROJECT_DIR/.git/config`. – Anshul Goyal Sep 10 '14 at 04:45
  • 1
    @JoshuaJohnson Were you able to resolve this? if my answer helped, dont forget to accept it :) – Anshul Goyal Sep 14 '14 at 18:13
  • I am on Win7, and only find it in $PROJECT_DIR/.git/config. Doesn't resolve the issue for me, still not prompting after delete these lines. – Jirong Hu Feb 11 '16 at 21:30
0

1.Go to your Repository folder (on PC).

2.Use HTTPS protocol instead of SSH, You'll get it while cloning.

git remote set-url origin https://.... 

3.git credential-cache exit

4.Done!

To revert it back to NOT ask password everytime:

1.Copy SSH key (~/.ssh/id_rsa.pub) from your device.

2.Paste it to Account --> SSH & GPG keys --> New SSH key.

3.Use SSH protocol instead of HTTPS, You'll get it while cloning.

git remote set-url origin git@:..//.... 
DARK_C0D3R
  • 2,075
  • 16
  • 21