Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5468005
  • 博文数量: 922
  • 博客积分: 19333
  • 博客等级: 上将
  • 技术积分: 11226
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-27 14:33
文章分类

全部博文(922)

文章存档

2023年(1)

2020年(2)

2019年(1)

2017年(1)

2016年(3)

2015年(10)

2014年(17)

2013年(49)

2012年(291)

2011年(266)

2010年(95)

2009年(54)

2008年(132)

分类: LINUX

2015-07-16 18:08:33

repo的配置和使用比较麻烦,有时候我们需要只下载部分git项目进行工作。
这里是编写的一个简易脚本,可以同时对当前目录下的多个git项目做共通的操作,
效果类似:repo forall -c 'git xxx'
不过不需要依赖repo相关的配置。
$ cat ~/bin/gits.sh

点击(此处)折叠或打开

  1. #!/bin/bash
  2. #This file used for git operation for multi git projects.
  3. #It is like repo, but only simple git common operation for the sub git projects.
  4. #It will operate all the git projects in current dir.

  5. #Currently it supports:
  6. #git branch, git pull, git checkout, git status, git reset
  7. #help:
  8. #

  9. _base_dir=`pwd`
  10. _git_dirs=`find . -type d -name .git |sed s/.git$//g`
  11. for _git_proj in $_git_dirs
  12. do
  13.     echo $_base_dir/$_git_proj
  14.     echo "====================================="
  15.     cd $_base_dir/$_git_proj
  16.     if [ $# -eq 0 ]
  17.     then
  18.         echo "operate path:$_git_proj"
  19.     else
  20.         git $*
  21.     fi
  22.     echo
  23. done


阅读(1857) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~