Home > Net >  Lock/Unlock a github branch
Lock/Unlock a github branch

Time:03-01

How can I lock a github develop branch so that no one can merge PR (even if PR approved) until I unlock the branch? This is needed because I want to create a release branch, out of develop and restrict unintended merge until branch out. I went through branch protection rules and it does not serve my purpose i.e. there is no option that says lock/unlock a branch.

Explanation: I have a develop branch and developers can create feature branches from develop branch and raise PRs, and once PRs get reviewed and get approval, developers can merge their PRs to develop. Now, I want to create a release branch from develop so I want to restrict all the developers to be able to merge their PRs to develop branch even if PRs got approved. It may take a few days to create a release branch because whatever code I have in develop branch, I want to test and by this testing time, I want to lock the develop branch, so that no one can merge their PRs into develop branch. Once testing successfully done, I will create a release branch from develop and I will then unlock the develop branch, so that, from now on developers can merge their PRs to develop branch.

CodePudding user response:

You can create a branch at any time from any commit, there is no reason to lock an active branch and prevent people from working.

git checkout -b <new branch name> <commit hash>, then git push.

CodePudding user response:

This functionality is not available in git itself. This can be handled by whichever server you use to manage the repo. See Managing a branch protection rule @ Github. You can set rules by branch name or pattern and require a PR to merge to that branch. You should also be able to set who can merge and other rules related to branch management.

  • Related