git - Azure DevOps 和使用 Git LFS 锁定文件:推送期间是否验证了锁定?
问题描述
我是 Git LFS 锁定功能的新手,并且对它如何与 Azure DevOps 一起工作有疑问。它只是向本地分支添加只读标志吗?或者服务器上是否有一些魔法可以防止更改远程分支上的锁定文件?
例如,我能够在本地更改锁定的文件,并将这些更改推送到远程分支,而 Azure DevOps 不会阻止“推送”。我希望有一些东西可以验证锁定的文件没有被推送到远程分支。样本:
# Verify lock
C:\repo> git lfs lock .\test.png
Lock failed: There is an existing lock on this path.
# Simulate an app that changes the read-only flag, and makes changes to .\test.png
C:\repo> attrib -r .\test.png
# I opened .\test.png in MSPaint and made changes to it.
# Stage and commit changed file
C:\repo> git add .
C:\repo> git commit -m "testing changing locked file"
[master 57031ee] testing changing locked file
1 file changed, 2 insertions(+), 2 deletions(-)
# Push commit. I'd expect this fail, since file is locked by another user, but it doesn't fail.
C:\repo> git push
Consider unlocking your own locked files: (`git lfs unlock <path>`)
* test.png
Uploading LFS objects: 100% (1/1), 11 KB | 0 B/s, done.
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 16 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 374 bytes | 374.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Analyzing objects... (3/3) (267 ms)
remote: Checking for credentials and other secrets... (1/1) done (4 ms)
remote: Checking path lengths for refs and files... done (5 ms)
remote: Storing packfile... done (161 ms)
remote: Storing index... done (102 ms)
To https://<myteam.visualstudio.com/DefaultCollection/<myproject>/_git/<myrepo>
5b2a9d6..57031ee master -> master
解决方案
推送提交。我预计这会失败,因为文件被另一个用户锁定,但它不会失败。
与您使用相同命令的行为相同,但根据此文档:Git LFS 将验证您在推送时没有修改被其他用户锁定的文件。
如果您希望 push 命令失败,请尝试相应的 git lfs 命令 ( git lfs push origin master --all
) 而不是正常的 git push 命令 ( git push origin master
)。
使用 git lfs push 命令的结果:
推荐阅读
- python - 模块不存在
- matplotlib - 使用 matplotlib 绘制 scikit learn 线性回归结果
- linux - How to use wget to download files that begins with a known expression and have a certain date after some unknown words?
- css - 无法将粘性物品放置在垫子标签内
- java - Spring数据查询dsl如何添加订单?
- sql - 如何从包含引用同一列的两个外键的 SQLite 表中获取信息
- recursion - 递归多态类型结构的更好表示
- node.js - 当 URL 参数与 Express 中的正则表达式不匹配时捕获错误
- php - 我无法让我的 if / else 语句显示 the_header_image_tag 与否。WordPress
- java - 如何使用 /src/main/resources 内嵌套文件夹中的属性文件?