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.
git clean -xdf is a great "sh*t hit the fan" command. It erases each and every file in your git directory which is NOT part of your repository. All additional files, such as the ones listed in your . gitignore , will be removed.
The git clean command also allows removing ignored files and directories.
git clean deletes ignored files only if you use either the -x or -X option, otherwise it just deletes untracked files.
You can work around by using the git
command directly, from gitpython
git = repo.git
git.clean('-xdf')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With