Git: force user and password prompt

后端 未结 6 1664
小鲜肉
小鲜肉 2020-12-04 13:13

I recently updated my local Git installation to 1.8.1 from 1.8.0.1.

I\'m noticing that, when I work on GitHub, it doesn\'t prompt me for

相关标签:
6条回答
  • 2020-12-04 13:40

    Since the question was labeled with Github, adding another remote like https_origin and add the https connection can force you always to enter the password:

    git remote add https_origin https://github.com/.../...
    
    0 讨论(0)
  • 2020-12-04 13:50

    Addition to third answer: If you're using non-english Windows, you can find "Credentials Manager" through "Control panel" > "User Accounts" > "Credentials Manager" Icon of Credentials Manager

    0 讨论(0)
  • 2020-12-04 13:51

    Add a -v flag with your git command . e.g. git pull -v

    v stands for verify .

    0 讨论(0)
  • 2020-12-04 13:52

    This is most likely because you have multiple accounts, like one private, one for work with GitHub.

    SOLUTION On Windows, go to Start > Credential Manager > Windows Credentials and remove GitHub creds, then try pulling or pushing again and you will be prompted to relogin into GitHub

    SOLUTION OnMac, issue following on terminal:

    git remote set-url origin https://username@github.com/username/repo-name.git
    

    by replacing 'username' with your GitHub username in both places and providing your GitHub repo name.

    0 讨论(0)
  • 2020-12-04 13:53

    With git config -l, I now see I have a credential.helper=osxkeychain option

    That means the credential helper (initially introduced in 1.7.10) is now in effect, and will cache automatically the password for accessing a remote repository over HTTP.
    (as in "GIT: Any way to set default login credentials?")

    You can disable that option entirely, or only for a single repo.

    0 讨论(0)
  • 2020-12-04 13:53

    None of those worked for me. I was trying to clone a directory from a private git server and entered my credentials false and then it wouldn't let me try different credentials on subsequent tries, it just errored out immediately with an authentication error.

    What did work was specifying the user name (mike-wise)in the url like this:

       git clone https://mike-wise@collab.somewhere.net/someuser/somerepo.git
    
    0 讨论(0)
提交回复
热议问题