【问题标题】:How to Clone Repository using GitPython如何使用 GitPython 克隆存储库
【发布时间】:2018-02-20 11:25:15
【问题描述】:

我是 Python 和 Git 的新手。找到了使用 Python 运行 Git 命令的 GitPython 库。我正在尝试将已在 Google Cloud 上创建的私有存储库克隆到我在 Mac 上的本地目录中。我的代码如下:

repo = Repo.clone_from('https://source.developers.google.com/p/my-project/r/my-project--data', 'my-local-dir', no_checkout=True)

我收到以下错误:

git.exc.GitCommandError: Cmd('git') failed due to: exit code(128) cmdline: git clone --no-checkout -v https://source.developers.google.com/p/my-project/r/my-project-data /my-local-dir stderr: 'Cloning into '/my-local-dir'... fatal: could not read Username for 'https://source.developers.google.com': Device not configured

请帮忙。 提前致谢。

【问题讨论】:

    标签: repository clone git-clone gitpython


    【解决方案1】:

    我尝试做同样的事情,然后我发现了pygit2,并且我能够使用两行代码克隆一个存储库。

    怎么样?首先确保你已经在你的 python 环境中安装了 pygit2。我使用以下命令行做到了这一点:

    pip install pygit2
    

    这里是我上面提到的两行:

    import pygit2
    pygit2.clone_repository("https://github.com/libgit2/pygit2", "pygit2")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-31
      • 2017-03-04
      • 2019-12-31
      • 2020-03-25
      • 1970-01-01
      • 2016-05-01
      相关资源
      最近更新 更多