如果更多的git命令在同一个仓库中并行运行,是否安全? [英] Is it safe if more git commands are run on the same repo in parallel?
问题描述
我感兴趣的是,如果可以安全地并行运行 git push
和 git commit
之类的东西(例如在cron工作,jenkins工作等)。 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屋!