我在像这样测试gitPython的克隆,
git.Repo.clone_from("https://github.com/nicothin/web-design.git","/home/tom/src",branch='master',recursive=True)但它总是会产生错误,
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/git/repo/base.py", line 885, in clone_from
return cls._clone(git, url, to_path, GitCmdObjectDB, progress, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/git/repo/base.py", line 831, in _clone
finalize_process(proc)
File "/usr/local/lib/python2.7/dist-packages/git/util.py", line 155, in finalize_process
proc.wait()
File "/usr/local/lib/python2.7/dist-packages/git/cmd.py", line 319, in wait
raise GitCommandError(self.args, status, self.proc.stderr.read())
ValueError: I/O operation on closed file有人能告诉我怎么解决这个问题吗?我试图修复GIT_PYTHON_GIT_EXECUTEABLE和GIT_PYTHON_TRACE,它们都不起作用。
发布于 2016-03-14 03:34:11
好吧,我自己修的。根据GitHub发布记录(如这 ),这是一个bug。我运行的是Ubuntu15.10,默认的GitPython版本是1.0.2,所以我无法调试它,因为我不知道git命令返回。
在我从GitPython github获得并安装了源代码之后,我就能够看到异常中发生了什么。它的结尾clone_from()命令的目标路径必须是一个新路径,如果它已经存在,将会引发一个git命令错误,所以我只是将它更改为
git.Repo.clone_from("https://github.com/nicothin/web-design.git","/home/tom/src/mustBeNewPath",branch='master',recursive=True)这个问题解决了。
https://stackoverflow.com/questions/35978769
复制相似问题