【SHELL】批量下载GIT代码
2016-06-02 19:10
477 查看
现在下载代码由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 ..
大功告成!!!
相关文章推荐
- android wifi 无线调试
- RPC failed; result=22, HTTP code = 411
- git更新已經刪除的文件
- 运维入门
- 动态清空 nohup 输出文件
- install scrapy with pip and easy_install
- 提取Git每次提交后Commit的文件
- GIT迁移服务器
- 分布式版本管理git入门指南使用资料汇总及文章推荐
- Linux Shell常用技巧
- Shell 脚本编程陷阱
- git终极指南:在实际开发中的应用
- shell字符串操作详解
- Shell中删除某些文件外所有文件的3个方法
- Ruby中执行Linux shell命令的六种方法详解
- VB使用shell函数打开外部exe程序的实现方法
- Shell编程的一些知识集合
- Shell中的for和while循环详细总结
- 什么是Shell?Shell脚本基础知识详细介绍
- Shell脚本中引用、调用另一个脚本文件的2种方法