2017-02-03 171 views
0

我有以下Python代碼:GIT許可拒絕(公鑰)

import subprocess 
import os 

repo_dir = 'C:\dev\codeRepo' 
os.chdir(repo_dir) 

process = subprocess.Popen("git pull", stdout=subprocess.PIPE) 
output = process.communicate()[0] 

我收到以下錯誤:

Permission denied (publickey). fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

注意,我有公共密鑰設置在服務器上,我可以從Windows命令行執行「git pull」,而不必輸入任何密鑰,並且它可以工作。但是,從Python程序中我得到這個錯誤。

回答

0

我找到了根本原因。

最初我有git設置這樣的方式,每個git pull它要求密鑰。爲了解決這個問題,我刪除了現有的密鑰,並添加了一個沒有密碼的新密鑰(還有其他方法)。由於我沒有重啓機器,所以這個改變並沒有被windows系統所接受。重啓後,我得到了它的工作。