Search code examples
gitazureversion-controlazure-devopsazure-repos

Can we lock a file in Azure DevOps?


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.


Solution

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