Git(LFS):什么是锁定支持?我应该启用它吗? [英] Git (LFS): what is locking support? And should I enable it?

查看:2023
本文介绍了Git(LFS):什么是锁定支持?我应该启用它吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,我第一次(至少是我第一次看)遇到了Git的以下评论:

Just today I ran across the following comment from Git for the first time (at least the first time I saw it):

Mikes-Mac$ git push
Locking support detected on remote "origin". Consider enabling it with:
  $ git config 'lfs.https://github.com/<my_repo>.git/info/lfs.locksverify' true
Everything up-to-date
Mikes-Mac$ 

这是什么Locking support?对于LFS(大文件存储),这是否是互斥锁?如果是这样,那么在git上运行任何东西不是绝对必要吗? (至少,如何才能建立日志历史记录的排序"?更糟糕的情况是,我不能通过同时写入破坏二进制文件吗?)

What is this Locking support? Is this some sort of mutex locking for the LFS (large file storage)? If so, isn't it absolutely essential to get anything on git to work? (Minimally, how else could the "ordering" of the log history be established? Worse case, couldn't I have a binary file corrupted by simultaneous writes?)

最近与该存储库没有任何不同,与使用LFS建立的其他存储库相比,我对该存储库也没有做任何更改.

I didn't do anything differently to this repository recently, nor have I done anything differently with this repository compared to any others that I've established with LFS.

因此,我假设这是向世界"提供的新评论,以便我们了解新功能.

I'm therefore assuming this is a new comment being provided to "the world" to let us know of new features.

但是,无论是Google搜索还是快速搜索他们的文档,都无法使我做出任何解释.所以,我不禁要问:

However, neither a Google search nor a quick search through their documentation led me to anything to explain this. So, I'm left wondering:

  • 此锁定是什么?
    • 是互斥体吗?如果是这样,没有它我的回购品怎么能起作用?
    • 这仅限于LFS吗?与普通的git文件锁定有何不同?
    • What is this locking?
      • Is it mutex? If so, how could my repo even function without it?
      • Is this limited to just LFS? How is it different from normal git file locking?

      推荐答案

      此处记录了对Git LFS的锁定支持 https://github.com/git-lfs/git-lfs/wiki/文件锁定.

      Locking support of Git LFS is documented here https://github.com/git-lfs/git-lfs/wiki/File-Locking.

      Git LFS v2.0.0包含文件锁定的早期版本.通过文件锁定,开发人员可以锁定他们正在更新的文件,以防止其他用户同时更新它们.在Git存储库中同时进行编辑将导致合并冲突,这在大型二进制文件中很难解决.

      Git LFS v2.0.0 includes an early release of File Locking. File Locking lets developers lock files they are updating to prevent other users from updating them at the same time. Concurrent edits in Git repositories will lead to merge conflicts, which are very difficult to resolve in large binary files.

      一旦.gitattributes中的文件模式是可锁定的,Git LFS将使其在本地文件系统上自动变为只读状态.这样可以防止用户在不先锁定文件的情况下意外编辑文件.

      Once file patterns in .gitattributes are lockable, Git LFS will make them readonly on the local file system automatically. This prevents users from accidentally editing a file without locking it first.

      Git LFS将验证您是否在推送时未修改其他用户锁定的文件.由于文件锁定是一个较早的版本,并且很少有LFS服务器实现API,因此Git LFS如果无法验证锁定的文件,将不会停止您的推送.您会看到这样的消息:

      Git LFS will verify that you're not modifying a file locked by another user when pushing. Since File Locking is an early release, and few LFS servers implement the API, Git LFS won't halt your push if it cannot verify locked files. You'll see a message like this:

      $ git lfs push origin master --all
      Remote "origin" does not support the LFS locking API. Consider disabling it with:
        $ git config 'lfs.http://git-server.com/user/test.locksverify' false
      Git LFS: (0 of 0 files, 7 skipped) 0 B / 0 B, 879.11 KB skipped
      

      $ git lfs push origin master --all
      Locking support detected on remote "origin". Consider enabling it with:
        $ git config 'lfs.http://git-server.com/user/repo.locksverify' true
      Git LFS: (0 of 0 files, 7 skipped) 0 B / 0 B, 879.11 KB skipped
      

      因此从某种意义上讲,您可以将其视为咨询互斥,因为:

      So in some sense you may consider it an advisory mutex, because:

      • 如果您不锁定"文件,则无法对其进行编辑
      • 使用git lfs lock锁定"文件后,就可以对其进行编辑,并且存储库服务器将识别出您正在对其进行编辑
      • 服务器将不接受更改他人锁定的文件的提交.
      • If you don't "lock" the file, you can't edit it
      • Once you "lock" the file with git lfs lock, you can edit it, and the repository server will recognize that you are editing it
      • The server will not accept commits changing the files you have locked by other people.

      主要是为了帮助团队管理大文件以防止合并冲突而添加的.

      It is mainly added to help team managing large files to prevent merge conflicts.

      这篇关于Git(LFS):什么是锁定支持?我应该启用它吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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