并发的git pull并从不同位置推送相同的远程回购 [英] concurrent git pull and push on same remote repo from different locations

查看:150
本文介绍了并发的git pull并从不同位置推送相同的远程回购的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我从某个远程git仓库中提取或克隆
如果
1)在我开始提取/克隆之后会发生什么 - 有人开始推动中间那个远程仓库?
2),而有人正在推送代码到远程git仓库 - 我开始拉克隆它?

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? 2) while someone is in the middle of pushing code to remote git repo - and I start pulling cloning it?

我最终会得到什么的情况下?

What do I end up with in each of the cases?

谢谢

Thanks

推荐答案

案件。在情况1)时,当某个人推送时更新ref(通常是分支名称),并且任何提取(克隆和拉取的重要部分)将在该点之前获取旧值或新一个之后。只有在所需的所有对象都在远程存储库的对象数据库中时,ref才会更新,因此这里没有问题。 2)类似地,如果提交的提取发生在被推送到的ref后被更新,那么你会得到新的值,否则你会得到旧的。

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. 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. 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.

(其中一个可能的例外是愚蠢的HTTP传输,您需要在远程存储库中运行 git update-server-info 推,所以有可能抓取后会立即失败,但在钩子运行该命令之前 - 但是,现在使用愚蠢的HTTP传输比较少见)。

(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.)

这篇关于并发的git pull并从不同位置推送相同的远程回购的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆