简体   繁体   English

将具有历史记录的完整远程 git 存储库备份到另一个远程服务器

[英]Backing up full remote git repository with history to another remote server

Assume that I have to GIT servers behind a fence, say at git.mycompany.com (with gitea UI) and at git.myclient.com (with github-like UI), both heavily security with VPN, multi factor-authentication etc. I want to deliver my full repository myProduct to git.myclient.com/alice/myProduct since Alice is my point of contact. Assume that I have to GIT servers behind a fence, say at git.mycompany.com (with gitea UI) and at git.myclient.com (with github-like UI), both heavily security with VPN, multi factor-authentication etc.我想将我的完整存储库myProduct交付给git.myclient.com/alice/myProduct ,因为 Alice 是我的联系人。

Can I do that directly without the detour over a local repository on my computer?我可以直接执行此操作而无需绕过计算机上的本地存储库吗?

Since I am working remote, and the uplink of mycompany.com is much faster than my own...由于我在远程工作,而且mycompany.com的上行速度比我自己的快很多...

My current lengthy and slow approach我目前漫长而缓慢的方法

In detail, the detour over my computer looks as follows:详细来说,我电脑上的弯路如下:

  1. Using the (github-like) user-interface, create an empty repository at git.myclient.com called myProduct .使用(类似 github 的)用户界面,在git.myclient.com创建一个名为myProduct的空存储库。
  2. Make sure that my local repository is up to date with git pull .使用git pull确保我的本地存储库是最新的。
  3. Check my current remote origin with git config --get remote.origin.url , see eg an answer to How can I determine the URL that a local Git repository was originally cloned from? Check my current remote origin with git config --get remote.origin.url , see eg an answer to How can I determine the URL that a local Git repository was originally cloned from?

    In my case, the result simply is https://git.mycompany.com/b--rian/myProduct.git就我而言,结果只是https://git.mycompany.com/b--rian/myProduct.git

  4. Change this configuration to the destination repository with git remote set-url origin git@git.myclient.com:alice/myProduct.git .使用git remote set-url origin git@git.myclient.com:alice/myProduct.git将此配置更改为目标存储库。
  5. Generate a key-value pair for ssh using ssh-keygen -o , see https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key使用ssh-keygen -o为 ssh 生成一个键值对,请参阅https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key
  6. Ask Alice to navigate to Settings > GPG and SSH keys (usually at https://git.myclient.com/settings/keys ) and ask her to add my New SSH key from the previous step.让 Alice 导航到Settings > GPG 和 SSH 密钥(通常在https://git.myclient.com/settings/keys )并让她从上一步添加我的新 Z765553E6C7AC8592C389ACB98780 密钥
  7. Make sure that the SSH agent is running on my windows box, if not start it with eval $(ssh-agent -s) inside the GIT Bash, see https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent Make sure that the SSH agent is running on my windows box, if not start it with eval $(ssh-agent -s) inside the GIT Bash, see https://help.github.com/en/github/authenticating-to -github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
  8. Now, finally, I can push most things to the client using git push --all origin .现在,最后,我可以使用git push --all origin将大部分内容推送到客户端。 This is the slow step which I would like to speed up.这是我想加快的缓慢步骤。
  9. The tags have to be pushed separately, I heard: git push origin --tags , see How do you push a tag to a remote repository using Git?标签必须单独推送,我听说: git push origin --tags ,请参阅如何使用 Git 将标签推送到远程存储库?
  10. Wind back everything by setting the remote.origin.url to back what it was in step 3, in my case it is a git remote set-url origin https://git.mycompany.com/b--rian/myProduct.git . Wind back everything by setting the remote.origin.url to back what it was in step 3, in my case it is a git remote set-url origin https://git.mycompany.com/b--rian/myProduct.git .

Is there an easier way?有没有更简单的方法?

Maybe you could use Git mirroring on git.myclient.com .也许您可以在git.myclient.com上使用 Git 镜像。

It's up to clients VCS (Git).这取决于客户 VCS (Git)。 Most implementations have mirroring options.大多数实现都有镜像选项。

For example, if the client is using Gitlab: https://docs.gitlab.com/ee/user/project/repository/repository_mirroring.html For example, if the client is using Gitlab: https://docs.gitlab.com/ee/user/project/repository/repository_mirroring.html

I think it would be much simpler to add a second remote... and then push into that remote:我认为添加第二个遥控器会更简单......然后推入那个遥控器:

git remote add second url-to-new-repo
git push second master develop # push master and develop to second

And so on.等等。

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

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