repo的配置和使用比较麻烦,有时候我们需要只下载部分git项目进行工作。
这里是编写的一个简易脚本,可以同时对当前目录下的多个git项目做共通的操作,
效果类似:repo forall -c 'git xxx'
不过不需要依赖repo相关的配置。
$ cat ~/bin/gits.sh
-
#!/bin/bash
-
#This file used for git operation for multi git projects.
-
#It is like repo, but only simple git common operation for the sub git projects.
-
#It will operate all the git projects in current dir.
-
-
#Currently it supports:
-
#git branch, git pull, git checkout, git status, git reset
-
#help:
-
#
-
-
_base_dir=`pwd`
-
_git_dirs=`find . -type d -name .git |sed s/.git$//g`
-
for _git_proj in $_git_dirs
-
do
-
echo $_base_dir/$_git_proj
-
echo "====================================="
-
cd $_base_dir/$_git_proj
-
if [ $# -eq 0 ]
-
then
-
echo "operate path:$_git_proj"
-
else
-
git $*
-
fi
-
echo
-
done
阅读(1933) | 评论(0) | 转发(0) |