Created
June 18, 2015 16:18
-
-
Save wanghongfei/2cadcc8bd44f908c295f to your computer and use it in GitHub Desktop.
清除git版本控制
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'wanghongfei' | |
# -*- coding:utf8 -*- | |
import os | |
# 删除指定目录下的所有文件 | |
def del_dir(base_path): | |
file_list = os.listdir(base_path) | |
for name in file_list: | |
abs_path = base_path + '/' + name | |
if os.path.isdir(abs_path): | |
print '删除目录%s' % abs_path | |
del_dir(abs_path) | |
os.rmdir(abs_path) | |
else: | |
os.remove(abs_path) | |
def process_dir(dir_path): | |
file_list = os.listdir(dir_path) | |
for name in file_list: | |
abs_path = dir_path + '/' + name | |
if os.path.isdir(abs_path): | |
if name == '.git': | |
print '删除目录%s' % abs_path | |
del_dir(abs_path) | |
os.rmdir(abs_path) | |
base_dir = os.getcwd() | |
process_dir(base_dir) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment