Batch clone Git project script under Windows

Introduction

This article shares a batch download script on Github or Gitlab. When there are dozens of projects, all warehouse codes can be downloaded in batches at one time.

1. Complete script

chcp 65001
@echo off

:克隆到本地目录,目录下不能存在与项目名相同的文件夹
SET folder=C:\xWorkspace\

:Git分组,没有分组可设为空,将`yourGroup`替换成你自己的组名
SET group=yourGroup

:同目录下,存放GIt项目名列表的txt文件,文件中的不同项目要换行
SET projectNames=%group%
:换成你的Git 地址
SET gitAddress=http://10.10.10.20/

echo ''
echo ----------------------------------------------------------
echo ********* start git clone %group% repositories ********
echo ****************** 开始克隆分组: %group%  *************
echo ----------------------------------------------------------
pause

:遍历
for /f %%i in (%projectNames%.txt) do git clone %gitAddress%%group%/%%i.git %folder%%group%\%%i

echo ''
echo ----------------------------------------------------------
echo export folder (导出路径):%folder%%group%
echo ********* all  repositories clone finished! ***************
echo ****************** 克隆任务结束 *************************
echo ----------------------------------------------------------
pause

1. Copy the above script into txt and rename it to xxx.bat.

2. The above script needs to modify the path and group name in it

Modify the location as follows:
①. Replace C:\xWorkspace\, with the location where you want to download the code.

SET folder=C:\xWorkspace\

②. Will be yourGroupreplaced with the group name on your GitHub.

SET group=yourGroup

③. Replace the address Github or Gitlab address with your own address

SET gitAddress=http://10.10.10.20/

3. Create a text document named "yourGroup" in the same level folder

Among them, "yourGroup" is the name of your group in the above step ②. Create a new text document and name it yourGroup.txt.
Write all the project names in it, like:

com-xxx-project-a
com-xxx-project-b
com-xxx-project-c
等等....

4. Then double-click the xxx.bat script to run

Then go to the directory you set and see if all the projects have been downloaded automatically.

Summarize

This script can help you and your team to download the project, and download the project to the local all at once.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324138989&siteId=291194637