简体   繁体   English

如何将变更集从脱机计算机推/拉到服务器?

[英]How do I push/pull changesets from an offline machine to a server?

The software project I am working on recently migrated from ClearCase to Git. 我正在研究的软件项目最近从ClearCase迁移到了Git。 I am still learning the fundamentals, so this question might be resolved later once I am more familiar with Git and its capabilities. 我仍在学习基础知识,因此,一旦我更熟悉Git及其功能,便可以稍后解决此问题。

My question is this: Does Git have a good workflow mechanism for a developer's machine that cannot connect to a central repository (ie., no network connection)? 我的问题是:对于无法连接到中央存储库(即没有网络连接)的开发人员的机器,Git是否具有良好的工作流程机制?

Details 细节

We have a centralized Git repository/server at our office (Location A). 我们在办公室(位置A)有一个集中的Git存储库/服务器。 Most developers will be able to connect to the server directly, whether it is through the LAN at the office or through VPN. 大多数开发人员将能够直接连接到服务器,无论是通过办公室的LAN还是通过VPN。 The security policy for this project does not allow any direct ssh/https connections to the server from outside the LAN - everything must go through VPN in that case. 此项目的安全策略不允许从局域网外部到服务器的任何直接ssh / https连接-在这种情况下,所有内容都必须通过VPN。

A developer on the team is moving to work on-site at a customer's facility (Location C). 团队中的开发人员正在转移到客户设施的现场工作(位置C)。 The developer will be working on a development machine at Location C that is offline only, and data can be transferred in and out of the machine using media (CD or DVD). 开发人员将在仅处于离线状态的位置C上的开发机器上工作,并且可以使用媒体(CD或DVD)在机器中进出数据。 The developer will need to have a branch or two of code on the offline machine, as he will be doing bug fixes, prototyping features for the customer, and acting as a front-line representative for the project. 开发人员将需要在脱机计算机上拥有一两个分支的代码,因为他将进行错误修复,为客户制作原型功能并充当项目的一线代表。

The developer will also have a machine at home (Location B) where he can connect to Location A using VPN and push/pull from the central repo. 开发人员还将在家中拥有一台机器(位置B),在这里他可以使用VPN连接到位置A,并从中央存储库进行推/拉。 We have tested this, and this works fine. 我们已经对此进行了测试,并且效果很好。

We are attempting to determine if it is possible to update the repository on the machine at Location C using DVDs. 我们正在尝试确定是否可以使用DVD在位置C的计算机上更新存储库。 The current repostitory is ~1.6GB source and 3GB of third-party binaries (we have not broken it up yet due to a huge amount of interconnectivity between various modules. It's a 25+ year old legacy R&D codebase). 当前的恢复源是〜1.6GB的源代码和3GB的第三方二进制文件(由于各种模块之间的大量互连性,我们尚未将其分解。这是25年前的旧有R&D代码库)。 After the initial clone, to update/pull the changes, would we need to burn the entire source to a disk, or can we use patches/archives to make it more efficient? 初始克隆后,要更新/拉动更改,我们是否需要将整个源刻录到磁盘,还是可以使用补丁/归档来提高其效率? If possible, I would like to maintain the history on the machine at Location C transparently (I know applying a patch makes a commit for it, but I don't believe it pulls the entire commit history for each item in the patch). 如果可能的话,我想透明地维护位置C上机器上的历史记录(我知道应用补丁会为此提交一个提交,但是我不相信它会拉出补丁中每个项目的整个提交历史)。

We will also need to go in the opposite direction (hence my desire to maintain the history). 我们还需要朝相反的方向前进(因此,我渴望保留历史)。 The bug fixes/features will need to be pushed back to the central repository, and the only way to export data is through a DVD. 错误修复/功能将需要推回中央存储库,而导出数据的唯一方法是通过DVD。 Would we need to burn the entire repository to a disk, or can we do this only through diffs? 我们是否需要将整个存储库刻录到磁盘,还是只能通过diff来做到这一点? In this case, keeping the version history is less important, but I'd like to maintain it if possible. 在这种情况下,保留版本历史记录就不那么重要了,但我想尽可能保留它。

We are testing various methods now (Git has only been live for about 3 working days for us), so I'm lacking a good deal of "what we've tried." 我们现在正在测试各种方法(Git对我们来说仅存在了3个工作日),因此我缺少很多“我们尝试过的方法”。 I'd like to see if anyone has done this or has done anything similar to this and collect any recommendations of workflows, tools, etc., to make this easier. 我想看看是否有人这样做或做了类似的事情,并收集有关工作流,工具等的任何建议,以简化此工作。 In the ideal world, once we have the repository set up at Location C, I would like to have small updates (only the changesets since the last pull) available through CD/DVD to the developer. 在理想的世界中,一旦我们在位置C设置了存储库,我想通过CD / DVD向开发人员提供小的更新(仅是上次提取以来的变更集)。

Specifics : Developer Machine will be Windows 7 x64, Central Repository is Atlassian Stash, the team generally uses SourceTree (but the developer is learning the Bash commands for Git to really understand it). 细节 :开发人员机器将是Windows 7 x64,中央存储库是Atlassian Stash,该团队通常使用SourceTree(但是开发人员正在学习Bash命令以使Git真正理解它)。 We are open to running scripts, 我们欢迎正在运行的脚本,

I did look at this question and it hints that patch files are a way to go; 我确实看过这个问题 ,它暗示修补程序文件是一种解决方法。 however, the requirements are different. 但是,要求是不同的。

You can zip a .git folder up and transfer it to another location (eg burned on DVD). 您可以向上压缩.git文件夹并将其传输到另一个位置(例如,在DVD上刻录)。 This will allow you to get the source inside. 这将使您能够获取源代码。 You can also unzip it and use git pull ../somewhere/unpackedgit to get changes both in and out. 您还可以解压缩它,并使用git pull ../somewhere/unpackedgit来获取更改。

You can however, use the git bundle command to create what is essentially off-line pushes which is what you need to get your updates back out. 但是,您可以使用git bundle命令创建本质上是脱机推送的东西,而这正是撤消更新所需的东西。 The git pro-book explains in detail how to do this, and has this introduction: git pro-book详细说明了如何执行此操作,并对此进行了介绍:

The scenario is thus: you need to sneakernet a git push. 因此,场景是:您需要对git push进行sneakernet。 Maybe your network is down and you want to send changes to your co-workers. 也许您的网络中断了,您想将更改发送给您的同事。 Perhaps you're working somewhere onsite and don't have access to the local network for security reasons. 也许您正在现场工作,并且出于安全原因无法访问本地网络。 Maybe your wireless/ethernet card just broke. 也许您的无线/以太网卡刚刚坏了。 Maybe you don't have access to a shared server for the moment, you want to email someone updates and you don't want to transfer 40 commits via format-patch. 也许您暂时无法访问共享服务器,您想通过电子邮件发送给他人更新,并且您不想通过格式补丁传输40个提交。

Enter git bundle. 输入git bundle。 The bundle command will package up everything that would normally be pushed over the wire with a git push command into a binary file that you can email or sneakernet around, then unbundle into another repository. bundle命令会将通常使用git push命令通过网络推送的所有内容打包成一个二进制文件,您可以在其中通过电子邮件或sneakernet对其进行打包,然后将其解捆绑到另一个存储库中。

"sneakernet" is slang for "moving files between computers by foot (wearing sneakers)" and a pun on "ethernet". “ sneakernet”是语,意指“在计算机之间步行(穿着运动鞋)移动文件”和“ ethernet”上的双关语。

If you want to transfer the last commit use 如果您想转移最后一次提交使用

git bundle create ../b1.bundle HEAD~..HEAD

(There are many ways to describe the range of the bundled commits.) (有很多方法可以描述捆绑提交的范围。)

This creates the file ../b1.bundle. 这将创建文件../b1.bundle。 You may bundle many commits into a single bundle file. 您可以将许多提交捆绑到一个捆绑文件中。 Then transfer somehow the bundle file to the other system. 然后以某种方式将捆绑文件传输到另一个系统。 On that system run 在该系统上运行

git bundle unbundle ../b1.bundle

This will create and print the commit(s) in your git repo as detached commits. 这将在git repo中创建并打印为分离提交的提交。 Let's say this command printed: 假设此命令已打印:

3db621f037d15cf00ad5f92b96cdd189c761a8f8

Then merge this commit into your branch: 然后将此提交合并到您的分支中:

git merge 3db621f037d15cf00ad5f92b96cdd189c761a8f8

And if you pulled some changes in your online system, you can bundle these and bring them back into your offline system too. 而且,如果您在联机系统中进行了一些更改,则可以将这些更改捆绑在一起,并将它们也带回到脱机系统中。

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

相关问题 我如何从没有互联网的远程机器上将比特桶推入或拉出 - How do i Push or pull to bitbucket from my remote machine which has no internet 如何避免在本地计算机上为git push / pull / fetch提供用户名和密码? - How do I avoid giving username and password to git push/pull/fetch on my local machine? 如何从GitHub克隆/拉出,但推送到Kiln? - How do I clone/pull from GitHub, but push to Kiln? 如何设置git从当前分支中推入和拉出? - How do I setup git to push and pull from the current branch? 如何将变更集从hg存储库导出到svn存储库 - How do I export changesets from hg repository to svn repository 如何在github上推送拉取请求? - How do I push to a pull request on github? 如何在对 vps 服务器执行 git push/pull 时禁用询问密码? - How do I disable asking password when doing git push/pull to vps server? 从本地机器上删除文件后,如何从 github 拉取以再次获取该文件? - After deleting a file from my local machine, how do I pull from github to obtain that file again? 从本地机器推送后,从远程 DigitalOcean 服务器上的 GitHub 存储库自动拉取? - Auto pull from GitHub repository on remote DigitalOcean server after push from local machine? 如何设置自动Git从Push到Bitbucket拉到Ubuntu服务器 - How can I setup automatic Git pull to Ubuntu server from Push to Bitbucket
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM