【发布时间】:2020-09-22 06:19:16
【问题描述】:
假设我必须在栅栏后面使用 GIT 服务器,比如git.mycompany.com(带有gitea UI)和git.myclient.com(带有类似 github 的 UI),两者都使用 VPN、多因素身份验证等高度安全. 我想将我的 完整 存储库 myProduct 交付给 git.myclient.com/alice/myProduct,因为 Alice 是我的联系人。
我可以直接执行此操作,而无需绕过我计算机上的本地存储库吗?
由于我在远程工作,而且mycompany.com的上行速度比我自己快很多...
我目前漫长而缓慢的方法
详细来说,我电脑上的弯路如下:
- 使用(类似 github 的)用户界面,在
git.myclient.com创建一个名为myProduct的空存储库。 - 确保我的本地存储库是最新的
git pull。 -
使用
git config --get remote.origin.url检查我当前的远程来源,参见例如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 - 将此配置更改为使用
git remote set-url origin git@git.myclient.com:alice/myProduct.git的目标存储库。 - 使用
ssh-keygen -o为ssh生成一个键值对,见https://git-scm.com/book/en/v2/Git-on-the-Server-Generating-Your-SSH-Public-Key - 让 Alice 导航到 设置 > GPG 和 SSH 密钥(通常在 https://git.myclient.com/settings/keys) 并要求她添加上一步中我的 新 SSH 密钥。
- 确保 SSH 代理正在我的 windows 机器上运行,如果没有在 GIT Bash 中使用
eval $(ssh-agent -s)启动它,请参阅 https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent - 现在,我终于可以使用
git push --all origin将大部分内容推送到客户端了。 这是我想加快速度的缓慢步骤。 - 标签要单独推送,听说:
git push origin --tags,见How do you push a tag to a remote repository using Git? - 通过将
remote.origin.url设置为第 3 步中的内容来回退所有内容,在我的情况下,它是git remote set-url origin https://git.mycompany.com/b--rian/myProduct.git。
有没有更简单的方法?
【问题讨论】:
标签: windows git github clone gitea