git subtree
命令。它可能有助于保持您的多个存储库同步。
--mirror
克隆,那么它预期本地分支并且可能无法直接读取“远程跟踪分支”,因此您可能需要创建和更新一些本地分支。
Initial Setup
mkdir $COLLECTION_REPO && cd $COLLECTION_REPO &&
git init
git remote add alpha <url/path-to-alpha-repo>
git remote add bravo <url/path-to-bravo-repo>
git remote add charlie <url/path-to-charlie-repo>
for r in $(git remote); do
git config --add remote.$r.fetch \
"$(git config remote.$r.fetch | sed -e 's.heads.tags.;s.remotes.tags/all.')"
git config remote.$r.tagopt --no-tags
done
Periodic Update
git remote update
git for-each-ref --shell --format \
'git branch --force --track -l all/%(refname:short) %(refname:short)' refs/remotes \
| sh
Initial Setup
mkdir $COLLECTION_REPO && cd $COLLECTION_REPO &&
git init
git remote add alpha <url/path-to-alpha-repo>
git remote add bravo <url/path-to-bravo-repo>
git remote add charlie <url/path-to-charlie-repo>
for r in $(git remote); do
git config remote.$r.fetch \
"$(git config remote.$r.fetch | sed -e 's.remotes.heads/all.')"
git config --add remote.$r.fetch \
"$(git config remote.$r.fetch | sed -e 's.heads.tags.g')"
git config remote.$r.tagopt --no-tags
done
Periodic Update
git remote update
refs/heads/all/<remote-name>/<branch-name-on-remote>
下的分支,但第一种方法还有一个重复的引用集合在refs/remotes/<remote-name>/<branch-name-on-remote>
下。第一种方法使用普通的fetch refspec,并使用git branch
将“远程跟踪分支”(refs/remotes/…
)复制到普通的本地分支(refs/heads/all/…
)中。第二种方法使用自定义refspec将获取的refs直接存储到目标ref层次结构中。git init --bare
和以.git结尾的仓库名称。另外,git config core.logAllRefUpdates true
可能是个好主意(因为在裸仓库中默认为false)。all/
前缀之外,这种方法与完全的--mirror
克隆之间的另一个区别是,refs/heads
和refs/tags
之外的引用不会被收集。大多数其他常见的引用都被认为是存储在仓库中的“本地”(这就是为什么它们不会被正常克隆复制)。其他一些引用是“远程跟踪分支”(refs/remotes
),一些是“二分记录”(refs/bisect
),git filter-branch
的“原始”ref备份(refs/original
)等等。可能这些其他的东西对于Redmine来说都不重要。如果它们很重要,也可以使用其他的refspec进行包含。