管理多个git项目的脚本

1910阅读 0评论2015-07-16 vaqeteart
分类:LINUX

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


上一篇:如果有一天你没有了动力,可以看看
下一篇:免费SSH Shell账号