0%

使用myrepos管理多Git仓库

介绍

  1. myrepos可以快速操作一批仓库, 不限于git, 且非常方便扩展
  2. 比起submodule来, 仓库间更加独立, 适合一些关系比较低的仓库
  3. 可以在某个子仓库下使用, 只操作当前仓库

工具地址

  1. http://myrepos.branchable.com/
  2. git://myrepos.branchable.com/
  3. *unix系列可以直接用包管理器安装, 搜索myrepos一般就可以了
  4. windows首先需要perl环境, 然后需要克隆库, 并把bin目录放在环境变量里面就行

eg:

  1. mr co 克隆所有
  2. mr up 更新所有
  3. mr status

批量注册

  1. ls |xargs -I {} sh -c 'cd {} && pwd && mr reg && cd -'

我的扩展后的实例

  • .mrconfig
  • 扩展了一些submodule的操作
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
[DEFAULT]
# gc
git_gc = git gc "$@"
# job num
#jobs = 8
# test cmd
git_fileLs = ls

# git submodule operators
git_subInit = git submodule update --init --recursive
git_subClean = git submodule foreach --recursive "git reset --hard HEAD && git clean -fd"
git_subBranch = git submodule foreach --recursive "git checkout $@"
git_subUpdate = git submodule foreach --recursive "git pull"
git_subRCmd = git submodule foreach --recursive "$@"

# change git local config for user and email
# eg: mr user puzzzzzzle 2359173906@qq.com
git_user = echo "$@"
git config user.name "$1"
git config user.email "$2"
echo name:
git config user.name
echo email:
git config user.email
# change git local config for user and email, include all submodule
# eg: mr ruser puzzzzzzle 2359173906@qq.com
git_ruser = echo "$@"
git config user.name "$1"
git config user.email "$2"
echo name:
git config user.name
echo email:
git config user.email
git submodule foreach --recursive "echo $@ && git config user.name $1 && git config user.email $2"

## your repos

[cpp_study]
checkout = git clone --recursive 'git@github.com:puzzzzzzle/cpp_study.git' 'cpp_study'