2010-08-20 104 views
0

我想設置我的密碼推只不拉。git密碼問題

有沒有辦法做到這一點?

+1

git不會做密碼。你使用什麼交通工具? – 2010-08-20 15:50:39

+1

設置傳輸並保護它是更多的ServerFault問題。我以各種方式做了它(gitosis,Apache + DAV,git-daemon),它不像編程。投票結束這個原因。 – 2010-08-20 15:58:08

+0

@Pavel:這可能是一個關於客戶端的問題,即使用不同的協議進行推送和拉取,因爲拉是一個只讀操作,並且通常不需要驗證。 – Cascabel 2010-08-20 16:03:45

回答

2

如果你有遠程倉庫進行交互的兩種不同的方式,其中一個需要密碼(用於推動)和其中一個不(拉),你可以這樣做:

[remote "origin"] 
    # the lightweight git protocol doesn't use passwords 
    # this will be used for fetch/pull 
    url = "git://git.foobar.org/foobar" 

    # this line is there by default; don't mess with it 
    fetch = +refs/heads/*:refs/remotes/origin/* 
    # SO, that's not a C comment... */ 

    # ssh requires password/key 
    # this will be used for pushes 
    pushurl = ssh://[email protected]/foobar 

在那裏替換正確的URL,你應該很好去。

+0

我必須修改哪個文件來設置此。我使用git GUI進行推送數據,使用git bash進行pull數據。我正在研究windows。 – 2010-08-20 16:08:52

+0

這在gitconfig這個特定的回購。你可以通過cd到repo來執行,並運行'git config remote.origin.pushurl'ssh:// user @ foobar.org/foobar''。 – Cascabel 2010-08-20 16:24:58