【SHELL】批量下载GIT代码
2016-12-05 10:37
337 查看
现在下载代码由SVN更换成GIT,代码仓库路径也从原来的一个变为多个,路径较多,记忆复杂,手工处理较慢。那有没有一种办法可以简单、方便处理呢?
当然有,这里将介绍我今天使用shell处理的方法。
已知:
1、输入:有类似如下的代码路径:git@example.com:framework/app_manager.git
2、输出:将所列出的代码路径全部下载到指定的文件夹下
以下为SHELL代码:
大功告成!!!
当然有,这里将介绍我今天使用shell处理的方法。
已知:
1、输入:有类似如下的代码路径:git@example.com:framework/app_manager.git
2、输出:将所列出的代码路径全部下载到指定的文件夹下
以下为SHELL代码:
#!/bin/sh #输入:git@example.com:framework/app_manager.git #输出:app_manager GetGitRepsName() { #echo "git@example.com:framework/app_manager.git"|sed 's;^.*\/\(.*\)\.git;\1;g' #这里提供了两种方法去找到app_manager #gname=`echo $1 | cut -d / -f 2 | cut -d . -f1` gname=`echo $1 |sed 's;^.*\/\(.*\)\.git;\1;g'` echo $gname } DownloadGitCode() { echo "processing : $1" git clone $1 echo "get target dir" dirname=`GetGitRepsName $1` echo "$dirname" cd $dirname pwd #忽略权限检查,这是为什么要获取dirname的原因 git config --add core.filemode false cd .. pwd echo } target_dir=default_git if [ $# -eq 1 ];then target_dir=$1 fi echo "create target folder:$target_dir" mkdir -p $target_dir rm -rf $target_dir/* cd $target_dir #将所需要的权限放到数组中,**注意‘\’前有一个空格** GIT_LIST_ARRAY=(\ "git@example.com:framework/app_manager.git" \ "git@example.com:framework/common_lib.git" \ "git@example.com:framework/flash_manager.git" \ "git@example.com:framework/javavm.git" \ "git@example.com:player/player.git" \ "git@example.com:player/pvr.git" \ "git@example.com:player/usb_manager.git" \ "git@example.com:dtv/resource_manager.git" \ ) #遍历数组,逐步处理 for gg in ${GIT_LIST_ARRAY[@]} do echo "input:$gg" DownloadGitCode $gg done cd ..
大功告成!!!
相关文章推荐
- 【SHELL】批量下载GIT代码
- Shell脚本实现批量下载网络图片代码分享
- Shell脚本实现批量下载网络图片代码分享
- Ftp批量上传下载的Shell脚本
- git 客户端 代码下载与提交
- FTP下打批量下载文件shell
- 在Windows下用Git下载Andorid4.0 源代码(批量脚本)
- 客户端Git代码的下载与提交
- 最全的用正则批量去除Teleport Pro整站下载文件冗余代码
- shell脚本下载安装mfs分布式文件系统,批量修改默认配置文件名
- LINUX手动安装git及repo android代码下载方法
- shell学习之检测批量下载成功与否
- 批量下载百度博客所有的 css 代码
- 用 shell 脚本批量下载畅想听吧(CXT8)和 有声下吧(YSX8)的有声小说
- 为C++代码批量添加版权信息的shell脚本
- git 客户端 代码下载与提交
- Windows XP下git通过代理下载android代码
- Python代码练习--批量下载(改进篇)
- git 代码下载