Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 670
Paddre Avatar asked Feb 17 '15 19:02

Paddre


People also ask

What does git clean Xdf do?

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.

Does git clean remove ignored files?

The git clean command also allows removing ignored files and directories.

Does git clean delete files?

git clean deletes ignored files only if you use either the -x or -X option, otherwise it just deletes untracked files.


1 Answers

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

git = repo.git
git.clean('-xdf')
like image 182
Marcus Müller Avatar answered Sep 23 '22 20:09

Marcus Müller