Search code examples
gitgit-lfs

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


When using git push I receive a number of the following console outputs:

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

I kind of understand what LFS locks are supposed to do, but I am not quite sure what happens if I don't enable them. Are they enabled on the server? Or on the client? Can anyone shed some light on this? Should I always enable it, if possible? Thank you!


Solution

  • I believe locking is implemented on git servers, but different git hosts might implement it differently, or not support it yet. Locally, you can configure your repository to check remote locking before pushing. I assume if this is not configured locally, your git commands will still transfer large files on git push, even if they are locked in the server, which will potentially just waste your time and network, if your remote host server does not implement early verification.

    I think this setting is just a workaround to for inconsistencies in how different providers (GitHub, bitbucket, gitlab, azure) implement locking.

    It seems the default value for this is null, and if null, git lfs will automatically set to true or false based on server response.

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

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