I have my keys in ~/.ssh/
and on other computers I can push and pull from the repo in question.
Why on one computer do I always need to enter my github username/password but not on others?
What could I change to avoid this and use my ssh keys instead ?
This can be changed by changing the authentication protocol method from https to ssh
One option would be to rename or delete the existing repo and then 'reclone' with the different method. So after mv
ing or rm -r
ing the current repo, the clone command will be something like
git clone [email protected]:user_name/repo_name.git
You can see the difference in the two approaches with the git config -l
command:
For https:
...
remote.origin.url=https://github.com/user_name/repo_name.git
...
For ssh
...
[email protected]:user_name/repo_name.git
branch.master.rebase=true # This was also created in the ssh method
...
You can see the difference in the .git/config
file for each repo:
rebase = true
in ssh[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = https://github.com/user_name/repo_name.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = [email protected]:user_name/repo_name.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
rebase = true
So if you want to just change the authentication method without 'recloning' the entire repo you can just edit the projects .git/config
and change
url = [email protected]_name/repo_name.git
to
url = https://github.com/user_name/repo_name.git
plus add
rebase = true
at the bottom, in the "[branch "master"]
" section
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments