使用与当前unix用户不同的用户进行git推送

时间:2012-06-21 21:02:32

标签: git

我正在尝试用git创建一个新的repo。服务器是https。我以另一个无权进入服务器的用户身份登录。我可以使用特定用户名推送吗?我做了以下事情:

git remote add origin ssh://git.example.com/repo/project.git
git config auth
git config credential.https://git.example.com/repo/project.git username@example.com
git push -v origin master

例如,我被要求以流浪者身份登录,而不是username@example.com:

vagrant@lucid64:~/django_projects$ git push origin master
vagrant@git.frogdesign.com's password: 

2 个答案:

答案 0 :(得分:4)

尝试:git remote set-url origin ssh://user@git.example.com/repo/project.git

答案 1 :(得分:1)

git config credential.https...中有一个小错误。

应该是:

git config credential.https://github.com/repo/project\.git.username [YOUR_EMAIL]

应该是'project \ .git',而不是'project.git'。

不要忘记'\',转义字符。

您可以less .git/config查看它:

[credential "https://github.com/repo/project.git"]
    username = [YOUR_EMAIL]

git config vim .git/config做同样的工作

git config --global 做同样的工作vim ~/.gitconfig

您可以man git-configman gitcredentials获取更多信息。