我正在尝试为我的用户制作一个小程序,用于 git 和其他的基本操作。而且我在克隆私有远程存储库时遇到了很多问题。
我有以下配置:在远程服务器上建立了 Python 3.4 Windows GitPython Ssh 连接。
这是我的代码:
print(blue + "Where to clone repos ?")
path_repo = input(cyan + "> " + green)
try:
assert os.path.exists(path_repo)
except AssertionError:
print(red + "Path does not exist")
continue
print(blue + "Name of Repos :")
name_repo = input(cyan + "> " + green)
remote_path = "git@dev01:/home/git/repos/{0}.git".format(name_repo)
local_path = "{0}/{1}".format(path_repo, name_repo)
# Repo.clone_from(remote_path, local_path)
repo = Repo.clone_from(remote_path, local_path)
#print(repo.git.fetch())
#print(repo.git.pull())
#print(repo.git.status())
这不会引发错误,但脚本会在最后停止并阻塞终端(给我无限的空行,没有>>>
)
运行之后,如果我进入 Git Bash 并输入git status
他似乎没有创建分支,只需初始化。因此,我添加了代码的最后 3 行以查看发生了什么变化,但什么也没有。
如果我在 Git Bash 中输入git pull
,他会很好地拉出 master 分支......
如果有人可以解决我的问题吗?
我在哪里犯了错误?
谢谢