10

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.

1 Answer 1

16

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")
Sign up to request clarification or add additional context in comments.

3 Comments

This function does not seem to exist
@WalterSvenddal are you really using gitpython or one of the other git wrappers for python maybe? I haven't tried this myself in 8, maybe 9 years.
@WalterSvenddal does this more complete example help?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.