批量clone代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/python
# -*- coding:utf-8 -*-
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
#!/usr/bin/python
# -*- coding:utf-8 -*-
import os
import time
dir_route = 'E:/code'
# 切换到test目录
os.chdir(dir_route)
current_directory = os.getcwd()
dirs = os.listdir()
# 定义git命令
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)