Skip to content Skip to sidebar Skip to footer

How To Delete Directory Containing .git In Python

I am not able to override/delete the folder containing .git in python. I am working on the below configuration: OS - Windows 8 Python - 3.5.2 Git - 2.9.2 Any Help would be apprec

Solution 1:

You should be using shutil to remove a directory that's not empty. If os.rmdir is used on a directory that's not empty an exception is raised.

import shutil

shutil.rmtree('/.git')

Solution 2:

try this code

import shutil
shutil.rmtree('/path/to/your/dir/')

Solution 3:

try this, It will work

os.system('rmdir /S /Q "{}"'.format(baseDirectory)) 

Post a Comment for "How To Delete Directory Containing .git In Python"