簡體   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.我想將我的完整存儲庫myProduct交付給git.myclient.com/alice/myProduct ,因為 Alice 是我的聯系人。

我可以直接執行此操作而無需繞過計算機上的本地存儲庫嗎?

由於我在遠程工作,而且mycompany.com的上行速度比我自己的快很多...

我目前漫長而緩慢的方法

詳細來說,我電腦上的彎路如下:

  1. 使用(類似 github 的)用戶界面,在git.myclient.com創建一個名為myProduct的空存儲庫。
  2. 使用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?

    就我而言,結果只是https://git.mycompany.com/b--rian/myProduct.git

  4. 使用git remote set-url origin git@git.myclient.com:alice/myProduct.git將此配置更改為目標存儲庫。
  5. 使用ssh-keygen -o為 ssh 生成一個鍵值對,請參閱https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key
  6. 讓 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
  8. 現在,最后,我可以使用git push --all origin將大部分內容推送到客戶端。 這是我想加快的緩慢步驟。
  9. 標簽必須單獨推送,我聽說: 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 .

有沒有更簡單的方法?

也許您可以在git.myclient.com上使用 Git 鏡像。

這取決於客戶 VCS (Git)。 大多數實現都有鏡像選項。

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

我認為添加第二個遙控器會更簡單......然后推入那個遙控器:

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

等等。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM