如果更多的git命令在同一个仓库中并行运行,是否安全? [英] Is it safe if more git commands are run on the same repo in parallel?

查看:119
本文介绍了如果更多的git命令在同一个仓库中并行运行,是否安全?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我感兴趣的是,如果可以安全地并行运行 git push git commit 之类的东西(例如在cron工作,jenkins工作等)。 git中是否有内置的锁定机制,所以这些操作是序列化的,否则这会破坏存储库?

Git通过以允许的方式编写引用来工作。如果您在推送的同时进行提交,则只会从引用到它们包含的对象。如果提交完成并更新分支引用,它将被推送。如果没有,旧的参考将被推送。你不会得到一半的提交。



所有文件的写入方式都隐含地保留了任何指针的参照完整性。最后写的文件将成为引用,它已经拥有它的所有依赖关系。


I am interested if it is safe to run things like git push and git commit in parallel (for example in cron jobs, jenkins jobs etc.). Is there some locking mechanism built-in in git so these operations are serialized or this can corrupt the repository?

解决方案

Yes. Git works by writing references in a manner that allows for this. If you are doing a commit at the same time as a push, push will only go from the references down to the objects they contain. If the commit finishes and updates the branch reference on time, it will get pushed. If it doesn't, the old reference will be pushed. You won't get "half a commit" pushed up.

All files are written in a manner that implicitly preserves referential integrity for any pointers. The last file written will be the reference that already has all it's dependencies there.

这篇关于如果更多的git命令在同一个仓库中并行运行,是否安全?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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