Paddre
Paddre

Reputation: 828

git-clean with GitPython

Is there any way to do something like git clean -d -x -f using GitPython?

I need to reset working directories and want to get rid of all unversioned files without deleting the whole folder (except for .git) and checking out again.

Upvotes: 10

Views: 3878

Answers (1)

Marcus Müller
Marcus Müller

Reputation: 36346

You can work around by using the git command directly, from gitpython

More complete example:

import git
repo = git.Repo("/path/to/repo")
repo.git.clean("-xdf")

Upvotes: 15

Related Questions