如果我没有 git lfs 锁会怎样

What happens if I don't have a git lfs lock

使用 git push 时,我收到以下控制台输出的一些信息:

Locking support detected on remote "origin". Consider enabling it with:
  $ git config lfs.https://127.0.0.1/foo/bar.git/info/lfs.locksverify true

我有点理解 LFS 锁应该做什么,但我不太确定如果我不启用它们会发生什么。他们在服务器上启用了吗?还是在客户端?任何人都可以阐明这一点吗?如果可能的话,我应该始终启用它吗?谢谢!

我相信锁定是在 git 服务器上实现的,但不同的 git 主机可能会以不同的方式实现它,或者还不支持它。在本地,您可以配置您的存储库以在推送之前检查远程锁定。我假设如果这没有在本地配置,你的 git 命令仍然会在 git 推送时传输大文件,即使它们被锁定在服务器中,这可能只会浪费你的时间和网络,如果你远程主机服务器未实施早期验证。

我认为此设置只是解决不同提供商(GitHub、bitbucket、gitlab、azure)实现锁定方式不一致的一种解决方法。

似乎默认值为空,如果为空,gitlfs 将根据服务器响应自动设置为真或假。

来自https://manpages.debian.org/testing/git-lfs/git-lfs-config.5.en.html

lfs.<url>.locksverify Determines whether locks are checked before Git pushes. This prevents you from pushing changes to files that other users have locked. The Git LFS pre-push hook varies its behavior based on the value of this config key.

  • null - In the absence of a value, Git LFS will attempt the call, and warn if it returns an error. If the response is valid, Git LFS will set the value to true, and will halt the push if the user attempts to update a file locked by another user. If the server returns a 501 Not Implemented response, Git LFS will set the value to false.
  • true - Git LFS will attempt to verify locks, halting the Git push if there are any server issues, or if the user attempts to update a file locked by another user.
  • false - Git LFS will completely skip the lock check in the pre-push hook. You should set this if you´re not using File Locking, or your Git server verifies locked files on pushes automatically.

来自https://github.com/git-lfs/git-lfs/wiki/File-Locking

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