python练习-批量clone项目代码和批量拉取代码
批量clone代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
import os import time
project_addr = [ 'git@gitlab.com:project/mengxixing-h5.git', 'git@gitlab.com:project/waterinbrainopendomain.git', 'git@gitlab.com:project/waterinbrain.git' ] os.mkdir('E:/code') os.chdir('E:/code') command = 'git clone ' for i in project_addr: os.popen(command + str(i)) time.sleep(1) print( i + " 拉取完毕!")
print('当前项目组已全部拉取完毕')
|
批量拉取代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
import os import time dir_route = 'E:/code'
os.chdir(dir_route) current_directory = os.getcwd() dirs = os.listdir()
command = 'git pull origin master' for code_dir in dirs: full_path = os.path.join(current_directory, code_dir) os.chdir(full_path) os.system(command) time.sleep(1) print(code_dir + " 拉取完毕!") os.chdir(dir_route)
|