Git 可以将一个裸存储库克隆到另一个裸存储库吗
我确信这是可以做到的,我只是不确定正确的方法。
我的场景是,此时将 USB 驱动器、本地硬盘驱动器和网络驱动器全部连接到我的 PC。本地硬盘将包含我本地工作的本地活动存储库。网络驱动器(具有很长的 UNC 路径!)将包含主要的裸存储库,充当上游参考副本(办公室中的 2 或 3 个协作者),而 USB 驱动器充当我的移动副本,用于连接到某些外部 PC(我的其他合作者有自己的驱动器,这可能会影响答案)。 (这是在 Windows msysgit 上)。
值得关注的是 USB 驱动器的设置,并确保我将工作流程引导到正确的方向(请参阅 using-git-on-usb-stick-for-travelling-code 。
- 我应该克隆本地存储库还是克隆网络存储库?
- 什么是确保 USB 驱动器正确卸载的特殊标志(-nohardlinks?)
- 等。
I'm sure this can be done, i'm just not sure of the right way.
My scenario is to have a USB drive, a local hard drive and a network drive all connected to my PC at this point. The local hard drive will contain the local active repo for my local work. The network drive (with a long UNC path!) would contain the main bare repo that acts as the upstream reference copy (2 or 3 collaborators in the office), while the USB drive acts as my mobile copy for sneakernetting to some external PCs (my other collaborators have their own drives, which may affect answers). (this is on windows msysgit).
It is the setting up of the USB drive that is the concern, and making sure I'm directing the workflow in the right direction (see using-git-on-usb-stick-for-travelling-code .
- Should I be cloning my local repo, or cloning the network repo?
- What are the special flags to make sure that the USB drive dismounts correctly? (-nohardlinks?)
- etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以从存储库创建一个裸到裸的克隆,并使用到 USB 记忆棒的长 UNC 路径,
但我怀疑这对您一步完成此操作是否有帮助。
鉴于您将在本地活动存储库中工作,我将在 USB 记忆棒上创建一个裸存储库,
在本地活动存储库中创建一个遥控器
,然后根据需要推送到它。
上面的命令假设您的 USB 记忆棒是 E: 并且您的工作目录位于本地活动存储库中。
据我了解您的问题,您至少有两组不相交的协作者,具体取决于您的其他协作者是否共享自己的公共中央存储库,或者都在独立的计算机上工作。这意味着您的 USB 记忆棒上的存储库是每个人(最终)都可以访问的存储库,因此您的队友将大部分时间都花在“飞机上”上。
设计开发流程的建议:
实现此目的的一种方法是让每个人都保持一个干净的 master 并仅在其他分支上进行更改。物理拥有 USB 记忆棒是一种自然的集成令牌,因此当给定的协作者拥有它时,顺序如下
You can create a bare-to-bare clone from the repo with the long UNC path to the USB stick with
but I doubt it buys you much to do it in one step.
Given that you'll be working in your local active repo, I'd create a bare repo on the USB stick
create a remote in your local active repo
and then push to it as necessary.
The commands above assume your USB stick is E: and that your working directory is within your local active repo.
As I understand your question, you have at least two disjoint sets of collaborators, depending on whether your other collaborators share a common central repository of their own or are all working on isolated machines. This means the repository on your USB stick is the repository to which everyone (eventually) has access, so your teammates spend most of their time “on a plane” with respect to it.
Suggestions for designing your development process:
One way you might do this is to have everyone keep a clean master and make changes only on other branches. Physical possession of the USB stick is a natural integration token, so when a given collaborator has it, the sequence goes
我建议创建主网络存储库的镜像克隆:
镜像克隆是一个裸存储库,具有与原始存储库相同的分支、标签等。
不必担心传递
--no-hardlinks
,因为不可能在文件系统之间进行硬链接。每当您想要更新 USB 镜像时,只需安装它并运行以下命令:
如果您曾经推送到 USB 驱动器镜像,将这些提交提交到主网络存储库的最佳方法是通过本地硬盘驱动器存储库:
I recommend creating a mirror clone of your main network repo:
A mirror clone is a bare repository with all the same branches, tags, etc. as the original repository.
Don't worry about passing
--no-hardlinks
because it's not possible to hardlink between file systems.Whenever you want to update your USB mirror, just mount it and run the following:
If you ever push into the USB drive mirror, the best way to get those commits to the main network repo is via your local hard drive repo:
您可以从任何一个克隆。 USB 驱动器完成后,您可以将其移除。您可以在使用后仔细检查完整性
You can clone from either. As soon as the usb drive finishes, you can remove it. You can double check integrity after with