Search code examples
pythongitgitpython

gitpython equivalent of git-apply


Is there a way to apply a patch (in the form of a diff file) to a repo using only the gitpython library?

In other words, is there a gitpython equivalent of the git-apply command?


Solution

  • Solution is to do

    r = Repo('path-to-repo')
    r.git.execute(['git','apply','patch.diff'])
    

    I had tried this before but I had omitted the 'git' at the beginning of the argument list, which gave an error about the command not existing.