ripper234
ripper234

Reputation: 230316

Troubleshooting git push - it asks for a user/pass

I'm using git on a new git linux computer. When I do git push, it me asks for user/password.

I've setup git properly, and in fact cloning the repo from github into a new folder works perfectly (using my public key, not the readonly copy). When I try to push from a previous clone I made to the same repo I get prompted for a user/pass.

Of course sshing into [email protected] works, and I made sure my public key is configured in github. Any ideas how to continue debugging?

Upvotes: 48

Views: 23578

Answers (7)

Joonho Park
Joonho Park

Reputation: 563

In my experience, there are three cases

1. git remote set-url github(remote repo name) https://github.com/id/a.git
    it asks ID/Passwd
2. git remote set-url github https://[email protected]/id/a.git
    it only asks Passwd
3. git remote set-url github git://github.com:id/a.git
    if you don't have a permission, it complains. So I can't use this for public server of github

all the commands are written to ".git/config"

Upvotes: 2

Amod
Amod

Reputation: 676

May be this will help someone like me.

Please find Git official article for caching your password

enter image description here

Link: https://help.github.com/en/articles/caching-your-github-password-in-git

Commands:

  1. Set Git to use the credential memory cache

    > git config --global credential.helper cache

  2. Change default cache timeout

    > git config --global credential.helper 'cache --timeout=3600'

Upvotes: 1

Guy
Guy

Reputation: 12512

Try the following:

git remote set-url origin [your git url, such as [email protected]:.../project.git]

Upvotes: 57

mihaicc
mihaicc

Reputation: 3102

this occurs because you did

git clone https://github.com/username/repo

instead of

git clone [email protected]:username/repo.git

Upvotes: 81

Prakash
Prakash

Reputation: 4617

if your repo Url is: https://github.com/abc/xyz.git

set url from command line as: git remote set-url origin [email protected]:abc/xyz.git

Replace https://github.com/ with [email protected]:

Upvotes: 7

Hassek
Hassek

Reputation: 8995

for mac If you have git 1.7.10+ it needs to use credential-osxkeychain for password caching. Here is a nice explanation:

https://help.github.com/articles/set-up-git

Upvotes: 1

manojlds
manojlds

Reputation: 301437

What do you mean by previous repo? Check the url of the origin from the previous repo's .git/config file. If you had cloned using http, it will ask for user/pass.

Upvotes: 44

Related Questions