Can we lock a file in Azure DevOps?
Asked Answered
W

3

5

I know that we can lock a branch in Azure Repos so that users can't push changes to it. Can we lock a particular file inside the branch so that it cannot be changed by other users?

Or can this be done in visual studio - team explorer? My current source control plugin is Git.

Wilbanks answered 4/7, 2019 at 4:32 Comment(1)
@HughLin-MSFT yes. The answers were really helpful.Wilbanks
A
5

You could lock the branch, require reviewers, automatically add the user responsible for the file you want locked as a reviewer when the file is modified (under "automatically include code reviewers"), and set the policy as "required".

That way no pull request including a change on the locked file can be accepted without the user responsible for the file approving it.

Arin answered 4/7, 2019 at 8:30 Comment(0)
H
3

No, this is not provided by Git (maybe through Git-LFS only).
And not exposed by Azure.

Azure only reference the .gitignore file, but does not mention any file locking mechanism.

Holdback answered 4/7, 2019 at 4:38 Comment(0)
R
1

As Sacha K said, you can set up a policy that protects a single file, and you can specify a reviewer. You can also specify that an impossible number of reviewers are required to change that file, like 999. And you can put in the "Activity feed message" that the file is locked and must not be changed.

Revocable answered 31/5, 2022 at 23:6 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.