是否可以在两个工作站之间使用 Git,而无需“中央”工作站?存储库?
我从 SVN 迁移到 Git 进行一些家庭编程,在我的 ReadyNAS 驱动器上设置了一个 Git 存储库。然后我创建了一个存储库,并将其克隆到两台不同的笔记本电脑上。
这些笔记本电脑都有已提交但未推送回中央存储库的更改;这是因为中央存储库/NAS 驱动器位于船上某处,并且 6-8 周内不会被看到!所以我的问题是,与此同时,我的两台笔记本电脑位于同一网络上,并且希望将本地存储库提交从一台笔记本电脑推送到另一台笔记本电脑。
这可能吗?我在两台笔记本电脑上运行 Windows,并在每台笔记本电脑上使用可安装的“Git Bash”。
I made the move from SVN to Git for some home programming, setting up a Git repository on my ReadyNAS drive. I then created a repository, which I cloned onto two different laptops.
These laptops both have changes that are committed but not pushed back to the central repository; this is because the central repository / NAS drive is on a boat somewhere and won't be seen for 6-8 weeks ! So my question is, in the meantime, I have both laptops on the same network and would like to push the local repository commits from one laptop to the other.
Is this possible ? I am running Windows on both laptops, and using the "Git Bash" installable on each one.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,当然。 git 存储库只是一堆文件,您所需要的只是某种访问它们的方式。例如,您可以在一台计算机的共享文件夹上设置一个裸露的“中央”存储库,然后从用于开发的两台计算机的本地克隆向该存储库推送/拉取。
Yes, sure. A git repository is just a bunch of files and all you need is some way to access them. For example, you could set up a bare "central" repository on one computer's shared folder and then push/pull to/from it from both computer's local clones that you use for development.
是的,你可以。即使两台笔记本电脑中的一台上没有额外的裸中央存储库(这将取代原来的中央存储库)。
在没有裸露的中央存储库的情况下工作的唯一缺点是您无法推回已签出的分支。假设您正在两台笔记本电脑上的 master 上工作,并从laptop1 克隆了laptop2 上的存储库。
在将更改从laptop2推回到laptop1之前,您必须
先在laptop1上执行a,然后才能执行推送:
否则推送将失败,因为您无法推送到已签出的分支。
推送后,在laptop1上再次查看master。
Yes, you can. Even without an additional bare central repo on one of the two laptops (wich would replace the original central repo).
The only drawback when working without a bare central repo is that you cannot push back to a checked out branch. Say, you're working on master on both laptops and cloned the repo on laptop2 from laptop1.
Before pushing back changes from laptop2 to laptop1, you have to do a
on laptop1 first, before you can execute the push.:
Otherwise the push will fail 'cause you cannot push to a checked out branch.
After the push, check out master again on laptop1.