How to lock a file in Azure Repository

47 views Asked by At

We have a requirement to lock a particular file in azure repos and not allow anyone to modify the file. I have seen a similar thread and talks about locking the branch and adding branch policy - Can we lock a file in Azure DevOps?, which we cannot do since we want to enforce this lock on the file for any new branches that get created from the master branch. Also adding a policy on a branch would require a build pipeline to run mandatorily which we do not want to do.

How can we lock an existing file across the entire repository?

1

There are 1 answers

1
Bright Ran-MSFT On

The Azure Git Repos does not support to lock particular files in the repositories.

If your projects really need this feature, I recommend you try to report a feature request on Developer Community. This will make it more convenient for the engineer teams to receive and understand your ideas. And your feedback also could be helpful for improving the Azure DevOps products.


In addition, if you use Git LFS in your repository, you can try to use the File Locking feature of Git LFS by add following line to the .gitattributes file within the git repository.

{file patterns} lockable

Git LFS will make the file patterns matched files read-only on the local file system automatically. This method only works when users clone the repository to local file system to edit files. It does not work when users directly edit files on the web UI of Azure Git Repos.