Azure DevOps和使用Git LFS锁定文件:推送期间是否验证了锁定?

问题描述 投票:0回答:1

我是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 azure-devops git-lfs
1个回答
0
投票

推送提交。我希望这会失败,因为文件已被另一个用户锁定,但它不会失败。

与使用相同命令的行为相同,但根据this documentGit LFS将验证您是否没有在推动时修改其他用户锁定的文件。

[如果您希望push命令失败,请尝试使用相应的git lfs命令(git lfs push origin master --all),而不是普通的git push命令(git push origin master)。

如果使用git lfs push命令,结果:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.