0

To pull a specific directory in the remote using git I would do:

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

How do I do the same using GitPython? I'm trying to figure it out but no cigar so far. I'm currently playing with something like the below, but i'm just getting errors. I'm clearly not using the git python api correctly.

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/")
Jamie Marshall
  • 1,885
  • 3
  • 27
  • 50

0 Answers0