我正在使用GitPython初始化一個新的本地資源庫,創建初始提交併推送到規範化的資源庫。不幸的是,最後一步是失敗,我很難理解爲什麼。我確定我只是使用GIT_SSH_COMMAND
變量錯誤,但我不知道如何。沒有太多的例子可以繼續。與GitPython一起使用GIT_SSH_COMMAND
我讀過this SO question,並挖掘到相關的issue和commit,但我顯然沒有把它放在一起正確。
幫助?
的Git V2.3的 「證明」 +
$ git --version
git version 2.3.1
腳本段
# Please take my word that I've init'd the repo and that any variables
# have been defined and initialized.
git_ssh_identity_file = os.path.expanduser('~/.ssh/id_rsa')
git_ssh_cmd = 'ssh -i %s' % git_ssh_identity_file
with git_project.git.custom_environment(GIT_SSH_COMMAND=git_ssh_cmd):
git_project.remotes.origin.push(git_project.heads.master)
產生的錯誤
Traceback (most recent call last):
File "./ct-new-project.py", line 204, in <module>
git_project.remotes.origin.push(git_project.heads.master)
File "/Library/Python/2.7/site-packages/git/remote.py", line 667, in push
return self._get_push_info(proc, progress or RemoteProgress())
File "/Library/Python/2.7/site-packages/git/remote.py", line 588, in _get_push_info
handle_process_output(proc, stdout_handler, progress_handler, finalize_process)
File "/Library/Python/2.7/site-packages/git/cmd.py", line 202, in handle_process_output
return finalizer(process)
File "/Library/Python/2.7/site-packages/git/util.py", line 158, in finalize_process
proc.wait()
File "/Library/Python/2.7/site-packages/git/cmd.py", line 300, in wait
raise GitCommandError(self.args, status, self.proc.stderr.read())
git.exc.GitCommandError: 'git push --porcelain origin master' returned with exit code 128
痛苦明顯的問題,所以我相信你已經檢查過它......但你永遠不知道。這是否從命令行工作?即'GIT_SSH_COMMAND ='ssh -i〜/ .ssh/id_rsa'git push - 瓷器原點大師'?以防萬一你的回購有問題。或者'GIT_SSH_COMMAND'特定於GitPython? – kdopen 2015-03-02 16:35:55
我應該說'你的回購狀態有問題'(因爲在推送失敗的原因與SSH覆蓋無關)。是的,我剛剛檢查過,'GIT_SSH_COMMAND'是一個'git'變量,而不是'GitPython',所以你應該能夠從命令行檢查。 – kdopen 2015-03-02 17:11:53
你知道嗎?是和不是。我試過了,但它肯定是在我以前有過別的不正確的一次迭代中。與此同時,我在'.git/config'中的出處與我試圖推動的代碼不同步 - 這是目前的實際問題 - 我試圖推動一個實際上並不存在的回購。 /懲罰headlap – 2015-03-02 17:48:26