Branch Lock Policies in Git

 

Can lock a specific branch from DevOps > Repos > Branches and select Lock

 

You can see a lock sign next to that branch

If you lock this branch, no one can push anything to this branch. Now till the time the lock is not removed.

 

 

 

Branch locks are primarily designed to prevent changes from being directly pushed to a branch. When a branch is locked, it typically means:

  • No new commits can be pushed directly to that branch.
  • Existing commits on that branch cannot be altered (e.g., through a force push).

 

A PR is a request to merge changes. Even if a branch is locked, you can still:

  • Create a branch from the locked branch.
  • Make changes in your new branch.
  • Create a PR to merge your changes into the locked branch.

 

These are the policies which you can put in place in order to restrict any developer from making unnecessary changes to your branches.


Related Question