我有一个 Gerrit 安装,其中有几个相关的项目(每个项目都在一个 git 存储库中)。另一个即将上线的项目也将使用gerrit,但为了整洁,我想将现有的一组项目放在一个新的超级项目下(以便在顶层看到“伞”项目. 我还想保留我们为此拥有的数据(例如,审查历史)。
如何去做这样的事情?另一种看待这个问题的方式是,如何将 gerrit 中的子项目从一个超级项目移动到另一个?
感谢今天早上我偶然发现的这篇博文,我找到了解决问题的可靠途径!虽然它并不完全简单,但它很健壮并且可以工作。
确保您已经创建了要将子项目重新设置为子项目的总括项目,并执行以下步骤:
MYGERRIT=ssh://${MYGERRIT_IP}:${MYGERRIT_PORT}
mkdir ~/x
cd ~/x
# Clone the repo for the subproject you want to re-parent
git clone ${MYGERRIT}/<subproject>
cd <subproject>
git fetch origin refs/meta/config:refs/remotes/origin/meta/config
git checkout meta/config
# Make changes to project.config
-----> inheritFrom = <your_umbrella_project_name>
# Commit changes
git add -A
EDITOR=vi git commit -a
# Push changes
git push origin meta/config:meta/config # If pushing directly
#git push origin meta/config:refs/for/meta/config # If going through gerrit
# Flush gerrit caches
ssh -p ${MYGERRIT_PORT} ${MYGERRIT_IP} gerrit flush-caches --cache project_list
ssh -p ${MYGERRIT_PORT} ${MYGERRIT_IP} gerrit flush-caches --cache projects