2012-06-21 32 views
4

我試圖用git創建一個新的回購站。服務器是https。我以另一個未被授權推入服務器的用戶身份登錄。我可以用特定用戶名推送嗎?我做到以下幾點:git推用不同的用戶比當前unix用戶

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 

例如有人問我登錄爲無業遊民,不[email protected]

[email protected]:~/django_projects$ git push origin master 
[email protected]'s password: 
+0

你解決了這個問題嗎?如果是這樣,請發佈答案並將其標記爲接受的答案,它將在未來幫助其他人:) – linkyndy

回答

4

嘗試:git remote set-url origin ssh://[email protected]/repo/project.git

+0

我在添加原點後添加了該行。我的密碼在提示符下不起作用。任何理由?當我改變SSH密碼工作,但我得到:錯誤:RPC失敗;結果= 52,HTTP代碼= 0 – prostock

1

有一個小錯誤在你的git config credential.https...

它應該是:

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

應該是 '項目\ 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以獲取更多信息。