def rmtree(path, chmod_files='auto', children_only=False, *args, **kwargs):
    "To remove git-annex .git it is needed to make all files and directories writable again first\n\n    Parameters\n    ----------\n    path: Path or str\n       Path to remove\n    chmod_files : string or bool, optional\n       Whether to make files writable also before removal.  Usually it is just\n       a matter of directories to have write permissions.\n       If 'auto' it would chmod files on windows by default\n    children_only : bool, optional\n       If set, all files and subdirectories would be removed while the path\n       itself (must be a directory) would be preserved\n    `*args` :\n    `**kwargs` :\n       Passed into shutil.rmtree call\n    "
    if (chmod_files == 'auto'):
        chmod_files = on_windows
    assert_no_open_files(path)
    path = str(path)
    if children_only:
        if (not isdir(path)):
            raise ValueError('Can remove children only of directories')
        for p in os.listdir(path):
            rmtree(op.join(path, p))
        return
    if (not (islink(path) or (not isdir(path)))):
        rotree(path, ro=False, chmod_files=chmod_files)
        if on_windows:
            path = ('\\\\?\\ '.strip() + path)
        _rmtree(path, *args, **kwargs)
    else:
        unlink(path)
To remove git-annex .git it is needed to make all files and directories writable again first

Parameters
----------
path: Path or str
   Path to remove
chmod_files : string or bool, optional
   Whether to make files writable also before removal.  Usually it is just
   a matter of directories to have write permissions.
   If 'auto' it would chmod files on windows by default
children_only : bool, optional
   If set, all files and subdirectories would be removed while the path
   itself (must be a directory) would be preserved
`*args` :
`**kwargs` :
   Passed into shutil.rmtree call
def rmtree(path, chmod_files='auto', children_only=False, *args, **kwargs):
    "To remove git-annex .git it is needed to make all files and directories writable again first\n\n    Parameters\n    ----------\n    path: Path or str\n       Path to remove\n    chmod_files : string or bool, optional\n       Whether to make files writable also before removal.  Usually it is just\n       a matter of directories to have write permissions.\n       If 'auto' it would chmod files on windows by default\n    children_only : bool, optional\n       If set, all files and subdirectories would be removed while the path\n       itself (must be a directory) would be preserved\n    `*args` :\n    `**kwargs` :\n       Passed into shutil.rmtree call\n    "
    if (chmod_files == 'auto'):
        chmod_files = on_windows
    assert_no_open_files(path)
    path = str(path)
    if children_only:
        if (not isdir(path)):
            raise ValueError('Can remove children only of directories')
        for p in os.listdir(path):
            rmtree(op.join(path, p))
        return
    if (not (islink(path) or (not isdir(path)))):
        rotree(path, ro=False, chmod_files=chmod_files)
        if on_windows:
            path = ('\\\\?\\ '.strip() + path)
        _rmtree(path, *args, **kwargs)
    else:
        unlink(path)