Reputation: 1135
Github is clear that it doesn't accept user names:
https://help.github.com/articles/error-permission-denied-publickey/
I try to set my remote repository as follows:
git remote set-url origin [email protected]:organization/reponame.git
When I do
git remote -v
it then shows
origin [email protected]:organization/reponame.git (fetch)
origin ssh://[email protected]/organization/reponame.git (push)
Why does my push URL still have a username?
Upvotes: 2
Views: 1555
Reputation: 488083
Normally, after:
git remote set-url origin [email protected]:organization/reponame.git
you would see both fetch and push URLs set to the same string. Since you are not seeing that, something must be slightly abnormal to begin with, and it's easy to predict what that is: you must have already set a --push
URL in some (any) way.
If you look inside .git/config
(or run git config --edit
, which will open the file in your default editor), you would typically see this:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = [email protected]:organization/reponame.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
(some values may be somewhat different). If you set a separate push URL using git remote set-url origin --push bad://url
, however, you will see that the middle section now reads:
[remote "origin"]
url = [email protected]:organization/reponame.git
fetch = +refs/heads/*:refs/remotes/origin/*
pushurl = bad://url
If you now use git remote set-url origin
to change the fetch URL, you will see that the push url remains set to whatever it was set to earlier. That is, until you use git remote set-url origin --push
, the bad://url
entry will stick around. You can remove it in various ways, or override it.
Removing it manually, or with:
git remote set-url origin --push --delete bad://url
and then running git remote -v
will show that the push URL is now defaulted to the fetch URL.
Because fetch and push are so old (dating back to before Git version 1.5), there are a lot of old compatibility hacks in this area. o11c mentioned pushInsteadOf
in a comment. This does not appear to be reflected in git remote -v
output, however.
Upvotes: 2