我正在使用GitPython從Gitlab服務器克隆存儲庫。如何使用GitPython?
git.Repo.clone_from(gitlab_ssh_URL, local_path)
後來我有嘗試更新此回購另一個腳本。
try:
my_repo = git.Repo(local_path)
my_repo .remotes.origin.pull()
except (git.exc.InvalidGitRepositoryError, git.exc.NoSuchPathError):
print("Invalid repository: {}".format(local_path)
此,除非在中間我籤這樣的標籤偉大的工作:
tag_id = choose_tag() # Return the position of an existing tag in my_repo.tags
my_repo .head.reference = my_repo.tags[tag_id]
my_repo .head.reset(index=True, working_tree=True)
在這種情況下拉動時,我得到一個GitCommandError:
git.exc.GitCommandError: 'git pull -v origin' returned with exit code 1
我已經閱讀了兩次文檔,我不知道問題出在哪裏。尤其是因爲如果我試圖用像SourceTree這樣的專用工具來拉回這個回購,它就沒有錯誤或警告。 我不明白我是如何檢查一個標籤的版本,即使分離的頭阻止我拉。
- 在這種情況下我該怎麼辦?
- 這裏發生了什麼,我錯過了什麼?
編輯:as建議我試着查看exception.stdout和exception.sterr,這裏沒有什麼用處(分別是b和'None)。這就是爲什麼我很難理解什麼是錯的。
可悲的是,stderr或stdout中沒有任何東西(分別是b'和None)。我唯一得到的是異常評論:'git pull -v origin'返回退出代碼1. 這就是爲什麼我在這裏有點迷路。 我並沒有做太多,只是創建一個新的git.Repo(路徑),並試圖拉。 – Rbtnk