代码之家  ›  专栏  ›  技术社区  ›  Jamie Marshall

GitPython来提取特定目录

  •  0
  • Jamie Marshall  · 技术社区  · 7 年前

    > git fetch <remote> <branch>
    > git checkout <remote>/<branch> -- relative/path/to/file/or/dir
    

    如何使用GitPython实现同样的功能?我正在想办法,但到目前为止还没有雪茄。我目前正在玩下面这样的游戏,但我只是得到了一些错误。我显然没有正确使用git python api。

    repo = git.Repo.init("local\repo\path")
    devRemote = repo.create_remote(\
        "Dev", "http:\\devremote.git")
    repo.create_head('master', devRemote.refs.master)
    repo.heads.master.set_tracking_branch(devRemote.refs.master)
    devOrigin.fetch()
    repo.heads.master.checkout("TargetDir/")
    
    0 回复  |  直到 7 年前