How do you delete a file with gitPython
Asked Answered
C

1

5

How do you delete a file with gitPython?

   repo.delete([file_to_delete])

says that there is no delete method.

Christology answered 31/10, 2017 at 17:14 Comment(0)
C
6

The problem I had was that I was deleting the file from the repository but not the working tree. The answer is to do the following:

repo.index.remove([file_to_delete],working_tree = True)

Without the working_tree argument the file is left in the working tree even though it is not in the repository.

Christology answered 31/10, 2017 at 18:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.