Asked 9 years, 9 months ago
Viewed 4k times
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?
asked Oct 28, 2015 at 15:45
chuck1chuck167577 silver badges2222 bronze badges
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.
answered Oct 28, 2015 at 16:47
chuck1chuck167577 silver badges2222 bronze badges
2You 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
answered Nov 7, 2018 at 8:50
1Start asking to get answers
Find the answer to your question by asking.
Ask questionExplore related questions
See similar questions with these tags.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4