这里是编写的一个简易脚本,可以同时对当前目录下的多个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