pythongitvcs-checkout

git checkout -f in python


I want to make a checkout on a version of a Git repository in Python. I am using the following code lines:

from git import Git
g = Git(os.getcwd())
g.checkout(row[2])

the question is how can I make a forced checkout?


Solution

  • From the documentation, the checkout method takes keyword arguments:

    g.checkout(row[2], force=True)
    

    Should do what you want.