简体   繁体   English

想要将 git 仓库从 git 客户端迁移到另一个 gitlab 服务器

[英]Want to migrate git repository from git client to another gitlab server

I am facing a situation where, I have two different git lab servers, consider "A" and "B".我面临的情况是,我有两个不同的 git 实验室服务器,考虑“A”和“B”。 I pulled one project repository from server "A" to my local client.我将一个项目存储库从服务器“A”拉到我的本地客户端。 Now, i want to push this local repository to server "B".现在,我想将此本地存储库推送到服务器“B”。 But during this migragtion, i want to keep all the previous commits and configs saved on new server too.但是在这次迁移期间,我也想将所有以前的提交和配置保存在新服务器上。 (which means, i cannot create a fresh repository on server "B" from the local data) (这意味着,我无法从本地数据在服务器“B”上创建新的存储库)

Note : I lost access to git server "A", and just have a local repository on git client, so cannot copy or export project directly from git server to server.注意:我失去了对 git 服务器“A”的访问权限,并且在 git 客户端上只有一个本地存储库,因此无法将项目直接从 git 服务器复制或导出到服务器。

All your history is kept in the .git folder that you have in local.您的所有历史记录都保存在本地的.git文件夹中。 So all your commits are already saved.所以你所有的提交都已经保存了。 But you will lose Gitlab A configuration since this is not related to git and Gitlab specific.但是你会丢失Gitlab A配置,因为这与 git 和 Gitlab 无关。 If you want to keep everything, you have to make the export if possible or you can keep only commits and git related stuff.如果您想保留所有内容,则必须尽可能进行导出,或者您只能保留提交和与 git 相关的内容。

You have to create a blank project on Gitlab B and follow the "Push an existing Git repository" steps :您必须在Gitlab B上创建一个空白项目并按照“推送现有的 Git 存储库”步骤操作:

cd existing_repo
git remote rename origin old-origin
git remote add origin https://gitlab_B_url/GROUP/PROJECT.git
git push -u origin --all
git push -u origin --tags

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM