Jim Yang
Jim Yang

Reputation: 307

Github trying to avoid being asked for credentials every time

I was working on our lab server and Github kept asking my username and password every time I tried to push or pull. After done some searching, I tried this command git remote set-url origin git@github.com:username/repo.git where username is replaced by my email address. Now I seemed now able to push to my repo. Any suggestions on how to fix this? Thanks in advance.

enter image description here

Upvotes: 0

Views: 91

Answers (2)

DDS
DDS

Reputation: 2478

If you use HTTP and don't mind your credentials being stored in plaintex you could use HTTP basic authentication:

https://username:password@git-repo/repo.git

#create a new remote with the authenticated url
git remote set-url authrepo https://username:password@git-repo.com/repo.git

#delete the old remote
git remote remove <your ocurrent remote>

#call the old remote the same as new remote
git remote rename authrepo <your current remote>

Upvotes: 0

Code-Apprentice
Code-Apprentice

Reputation: 83577

A URL like git@github.com:username/repo.git uses the SSH protocol for authentication. You need to create a SSH key and upload the public key to GitHub. The GitHub docs explain how to do this in detail.

Upvotes: 2

Related Questions