0

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?

Zoe
  • 27,060
  • 21
  • 118
  • 148
Amine Barrak
  • 139
  • 9

2 Answers2

1

From the documentation, the checkout method takes keyword arguments:

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

Should do what you want.

Jamey Hicks
  • 2,340
  • 1
  • 14
  • 20
0

According to reference checkout function takes first optional argument force=False checkout(force=False, **kwargs)

Therefore, you can just simply call it with first argument force=True, to force the force checkout, like this

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

John Smith
  • 160
  • 8