0

假设我必须在栅栏后面使用 GIT 服务器,比如在git.mycompany.com(使用gitea UI)和在git.myclient.com(使用类似 github 的 UI),两者都使用 VPN、多因素身份验证等高度安全。我想将我的完整存储库交付myProductgit.myclient.com/alice/myProductAlice是我的联络人。

我可以直接执行此操作而无需绕过计算机上的本地存储库吗?

由于我在远程工作,并且上行mycompany.com速度比我自己的要快得多...

我目前漫长而缓慢的方法

详细来说,我电脑上的弯路如下:

  1. 使用(类似 github 的)用户界面,在git.myclient.comcalled 创建一个空的存储库myProduct
  2. 确保我的本地存储库是最新的git pull.
  3. 检查我当前的远程来源git config --get remote.origin.url,例如查看如何确定本地 Git 存储库最初克隆的 URL

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

  4. 使用 .将此配置更改为目标存储库git remote set-url origin git@git.myclient.com:alice/myProduct.git
  5. 使用 为 ssh 生成键值对ssh-keygen -o,请参阅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)并让她添加上一步中的新 SSH 密钥
  7. 确保 SSH 代理正在我的 Windows 机器上运行,如果没有eval $(ssh-agent -s)在 GIT Bash 中启动它,请参阅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. 通过将 设置remote.origin.url回第 3 步中的内容来回退所有内容,在我的情况下,它是git remote set-url origin https://git.mycompany.com/b--rian/myProduct.git.

有没有更简单的方法?

4

2 回答 2

1

也许您可以在git.myclient.com.

这取决于客户 VCS (Git)。大多数实现都有镜像选项。

例如,如果客户端使用的是 Gitlab: https ://docs.gitlab.com/ee/user/project/repository/repository_mirroring.html

于 2020-06-03T14:24:06.823 回答
1

我认为添加第二个遥控器会更简单......然后推入那个遥控器:

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

等等。

于 2020-06-03T14:31:45.043 回答