Reputation: 9535
I'm trying to create a new repo with git. The server is https. I'm logged in as another user which isn't authorized to push into the server. Can I push with a specific username? I do the following:
git remote add origin ssh://git.example.com/repo/project.git
git config auth
git config credential.https://git.example.com/repo/project.git [email protected]
git push -v origin master
For example I get asked to login as vagrant, not [email protected]:
vagrant@lucid64:~/django_projects$ git push origin master
[email protected]'s password:
Upvotes: 4
Views: 5174
Reputation: 2669
There is a small wrong in your git config credential.https...
.
It should be :
git config credential.https://github.com/repo/project\.git.username [YOUR_EMAIL]
Should be ' project\.git ', not ' project.git '.
Do not forget the ' \ ', escape character.
You can less .git/config
to check it out:
[credential "https://github.com/repo/project.git"]
username = [YOUR_EMAIL]
git config
is doing the same job as vim .git/config
.
git config --global
is doing the same job as vim ~/.gitconfig
You can man git-config
and man gitcredentials
for more information.
Upvotes: 1
Reputation: 1922
Try: git remote set-url origin ssh://[email protected]/repo/project.git
Upvotes: 4