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 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.
You can use git directly, like this:
repo = git.Repo('repository_path')
repo.git.apply(['-3', 'patch-file'])
this will perform the git command:
git apply -3 patch-file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With