简体   繁体   English

如何将单个git分支从一台计算机移动到另一台计算机

[英]How to move a single git branch from one computer to another

I have a problem that I suspect may not have a solution, but no harm in asking 我有一个问题,我怀疑可能没有解决方案,但是问问没有害处

My firm uses Git Enterprise hosted on an internal server. 我的公司使用托管在内部服务器上的Git Enterprise。 Whilst my laptop is connected to the firm's network I have access to this remote repository, but when I am off the network, I do not. 当我的笔记本电脑连接到公司的网络时,我可以访问此远程存储库,但是当我不在网络上时,我却没有。 I can only work locally. 我只能在本地工作。

Separate to this, I have a virtualised computer hosted on our network. 与此分开的是,我在网络上托管了一台虚拟计算机。 This computer has access to Git Enterprise AND I can log into it from my laptop anywhere, both whilst on or off the network. 这台计算机可以访问Git Enterprise,并且无论在网络内还是网络外,我都可以从笔记本电脑随时随地登录它。

My situation is this. 我的情况是这样。 As I write this question, I am at home and off the network. 当我写这个问题时,我在家中并且不在网络中。 However I need to push my local branch up to Git Enterprise. 但是,我需要将本地分支机构推向Git Enterprise。 Is there anyway I can do this - maybe using my virtualised PC and possibly even a personal GitHub account? 无论如何,我可以做到这一点-也许使用我的虚拟PC甚至是个人GitHub帐户? My initial thought was to somehow push my local branch up to a private repo on my personal GitHub account, access my virtual PC to download that branch, then from there push it up to Git Enterprise. 我最初的想法是以某种方式将我的本地分支推到我的个人GitHub帐户上的私人仓库中,访问我的虚拟PC来下载该分支,然后从那里将其推到Git Enterprise。 The trouble is, I wouldn't know where to start. 麻烦是,我不知道从哪里开始。 I don't want to damage other branches either on my GitHub or Git Enterprise repos. 我不想破坏我的GitHub或Git Enterprise存储库上的其他分支。

Can this be done? 能做到吗?

Thanks 谢谢

on local computer you need create diff patch git diff branch origin/master > patch 在本地计算机上,您需要创建diff补丁git diff branch origin/master > patch

on the next computer you need to apply this branch: git apply patch 在下一台计算机上,您需要应用此分支: git apply patch

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

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