gpt4 book ai didi

Git (LFS) : what is locking support? 我应该启用它吗?

转载 作者:IT王子 更新时间:2023-10-29 01:28:48 39 4
gpt4 key购买 nike

"new"Git 评论:

就在今天,我第一次看到来自 Git 的以下评论(至少是我第一次看到它):

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$

这是什么锁定支持?这是某种 mutex locking 吗? LFS(大文件存储)?如果是这样,让 git 上的任何东西正常工作不是绝对必要的吗? (至少,如何才能建立日志历史记录的“排序”?更糟的情况是,我不能让二进制文件被同时写入损坏吗?)

我的操作

我最近没有对这个存储库做任何不同的事情,与我用 LFS 建立的任何其他存储库相比,我对这个存储库也没有做任何不同的事情。

因此,我假设这是向“世界”提供的新评论,让我们了解新功能。

没有明显的文档

但是,无论是通过 Google 搜索还是快速搜索他们的文档,我都没有找到任何解释这一点的方法。所以,我想知道:

  • 这是什么锁定?
    • 它是互斥体吗?如果是这样,没有它我的 repo 协议(protocol)怎么能运行?
    • 这仅限于 LFS 吗?它与普通的 git 文件锁定有何不同?
  • 为 LFS 添加锁定支持的优点和缺点是什么?

最佳答案

Git LFS 的锁定支持记录在此处 https://github.com/git-lfs/git-lfs/wiki/File-Locking .

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.

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

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

  • 如果不“锁定”文件,则无法编辑
  • 一旦您使用git lfs lock“锁定”了文件,您就可以编辑它,并且存储库服务器会识别出您正在编辑它
  • 服务器不会接受其他人更改您锁定的文件的提交。

添加主要是为了帮助团队管理大文件,防止 merge 冲突。

关于Git (LFS) : what is locking support? 我应该启用它吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42597408/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com