GIT:如何实现安全的并发推送? [英] GIT: How is safe concurrent push implemented?

查看:163
本文介绍了GIT:如何实现安全的并发推送?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们考虑使用不带守护程序的git的示例。

Let's consider the example when git is used without daemon.

因此我们没有git 服务器 ,我们只有中央存储库和两个用户及其git clients

So we don't have git "server", we only have central repo and two users with their git "clients".

因此,据我了解,添加新代码回购的工作将由用户的git程序(由客户端)完成。

So, as I understand the work for adding new code to repo will be done by git programs of the users (by clients).

如何提供安全的并发推送?

使用中央仓库操作系统文件锁定?

还是如何?

How is safe concurrent push provided?
Using central repo operating system file lock?
Or how?

推荐答案

防止并发推送的基本保护措施是:

The basic protections against concurrent push are:

  • avoiding concurrent push by pushing on dedicated branches
  • protecting a branch (GitHub protection or BitBucket protection in order to allow only an integrator to push on it
  • same idea (one integrator update a branch) by using forks (GitHub fork or BitBucket fork) in order to accept update only through pull requests.

但是从技术上讲,针对同一仓库的同一分支的并发推送取决于git backend 的管理方式ed。

建议中2016年3月发布的补丁 refs backend 。它将:

But technically, concurrent pushes against the same branch of the same repo depends on how the git backend is managed.
That is what is being improved in a proposed patch from March 2016 "refs backend". It will:


  • 使锁更通用(这意味着即使用户看不到锁,后端也已经有了锁机制)

  • < a href = http://marc.info/?l=git&m=145679363931390&w=2 rel = nofollow>首先解析符号引用(使用符号参考是-像HEAD 一样-常规文件,存储以 ref开头的字符串:refs / 。例如,您的 .git / HEAD 是一个常规文件,其内容为 ref:refs / heads / master 。)

  • making lock more generic (meaning there is already a locking mechanism on the backend side, even if there is no lock visible by users)
  • resolve symbolic refs first (with symbolic ref being -- like HEAD -- a regular file that stores a string that begins with ref: refs/. For example, your .git/HEAD is a regular file whose contents is ref: refs/heads/master.)

由于并发更新仍然可能使git混淆在锁定状态下不会发生
个符号引用的拆分

因此,在此操作过程中,符号引用可能会替换为普通引用,这将导致reflog中断并错过旧的-引用检查。

So a symbolic ref could be replaced by a plain ref in the middle of this operation, which would lead to reflog discontinuities and missed old-ref checks.

该补丁将提高实际并发更新的可靠性。

That patch would improve real concurrent update reliability.

这篇关于GIT:如何实现安全的并发推送?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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