简体   繁体   English

并发git pull并推送来自不同位置的同一个远程repo

[英]concurrent git pull and push on same remote repo from different locations

Suppose I'm pulling or cloning from some remote git repo What happens if 1) after I started pulling/cloning - someone start to push to that remote repo in the middle? 假设我从一些远程git repo中拉或克隆如果1)在我开始拉/克隆之后会发生什么 - 有人开始向中间的那个远程仓库推送? 2) while someone is in the middle of pushing code to remote git repo - and I start pulling cloning it? 2)当有人正在将代码推送到远程git repo时 - 我开始拉克隆了吗?

What do I end up with in each of the cases? 在每个案例中我最终会得到什么?

Thanks 谢谢

There's no problem in either case. 两种情况都没有问题。 In case 1) there'll be a point when the ref (a branch name, typically) is updated when someone's pushing, and any fetch (an essential part of clone and pull) will either get the old value before that point or the new one afterwards. 在案例1)中,当某人推动时,ref(一个分支名称,通常是)更新时会有一个点,并且任何获取(克隆和拉动的基本部分)将在该点或新的之前获得旧值之后一个。 The ref is only updated when all the objects required for it are in the remote repository's object database, so there's no problem there. 只有当它所需的所有对象都在远程存储库的对象数据库中时,才会更新ref,因此没有问题。 2) Similarly, if the fetch that makes up your pull happens after the ref that's being pushed to is updated, then you'll get the new value, otherwise you'll get the old one. 2)同样地,如果构成你的拉动的提取发生在被推送到的ref之后更新,那么你将得到新的值,否则你将获得旧值。

(One possible exception to this is the "dumb HTTP" transport, where you need to run git update-server-info in the remote repository after each push, so it's possible that a fetch will fail immmediately after a push but before the hook runs that command - however, it's relatively rare to use the dumb HTTP transport nowadays, I think.) (一个可能的例外是“dumb HTTP”传输,你需要在每次推送后在远程存储库中运行git update-server-info ,因此在推送之后但在挂钩运行之前,fetch可能会立即失败那个命令 - 但是,我认为现在使用愚蠢的HTTP传输是相对罕见的。)

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

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