我如何将我的 gitolite 迁移到 Gitlab
由于我的旧 gitolite 实例中有超过 100 个仓库,而我想迁移到 Gitlab 这个更易用的解决方案,我开发了一个
警告:这不是一个完整的脚本,而只是一个你需要根据特定需求修改的指南。我在 gitolite 中没有私有仓库,所以我的所有仓库都明确列在配置文件中。自行承担风险使用并做好备份! 这不会更改或删除 gitolite 中的任何仓库。无论如何,确保备份 gitolite 中的所有仓库,以防万一!
migrate_gitolite_to_gitlab.sh
# 配置 git 不要每次上传时都要求输入密码。
git config --global credential.helper store
# 准备仓库列表(检查文本文件并删除无效名称)
cat ~/gitolite-admin/*.conf |grep repo | cut -d' ' -f2 > repos.txt
# 克隆所有仓库
mkdir repos
cd repos
for i in $(cat ../repos.txt) ; do git clone git@myserver.org:${i} ; done
# 推送到 Gitlab。这将自动以当前用户身份创建新项目
for i in * ; do cd $i && git remote rm origin && git remote add origin "https://gitlab.myserver.org/yourusername/${i}.git" && git push origin master && cd ..; done
# 不要忘记备份你的 gitolite 仓库,以防出错!此脚本利用了你可以直接推送到 Gitlab 上的新仓库并在过程中创建项目的事实。你不需要手动创建项目。
运行此脚本时,我的 Gitlab 实例在仓库处于 git push 过程的最后阶段时崩溃了两次(这往往发生在千字节大小的小仓库上),原因是大量内存使用导致的重度交换。重启 gitlab 并重新运行脚本的推送到 gitlab部分修复了此问题。
注意 git config --global credential.helper store 将保持有效,以明文形式保存你的 git 密码。如果你想恢复将它们保存在 RAM 中 15 分钟的默认行为,在运行这些命令后使用 git config --global credential.helper cache。
Check out similar posts by category:
Git
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow