且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将一个Gitlab项目复制到另一个Gitlab存储库?

更新时间:2023-01-08 10:04:43

我会将原始项目克隆到本地计算机上的沙箱中,在所需的位置创建新项目,将新的gitlab位置设置为远程并推送在那里.

I would clone the original project in a sandbox on your local machine, create the new project where you want it, set your new gitlab location as the remote and push there.

假设old_url和new_url是您的新旧URL:

Assuming old_url and new_url are your old and new URLs:

git clone <old_url>
cd <repo_dir_name>
git remote add new_remote <new_url>
git push --all new_remote

假设新存储库在您执行此操作时为空,那么它将包含原始存储库中存在的所有分支和标签,而与之没有任何连接.

Assuming your new repo was empty when you did this, it will now contain all the branches and tags that exist in the original repo, without any connections to it.

PS:两年后我再次尝试回答,看来您需要 git clone --mirror< old_url> ,并添加了-mirror 开关,如果您希望将所有分支从原始存储库推送到新分支.如果以上方法都不适合您,请尝试使用-mirror .

PS: I tried my answer again two years later, and it appears you need git clone --mirror <old_url>, with the --mirror switch added, if you want all the branches from the original repo pushed to the new one. If the above doesn't work for you, try with --mirror.