DEV Community

baris
baris

Posted on

Answer: Is there a way to lock a branch in GIT

Lock a git branch

The branch being pushed to is the first parameter to the update hook. If you want to lock the branch myfeature for pushing, this code (placed in hooks/update) will do it:

#!/bin/sh
# lock the myfeature branch for pushing
refname="$1"

if [[ $refname == "refs/heads/myfeature" ]]
then
    echo

Top comments (1)

Collapse
 
gcnu profile image
seenu

Technically No,

because that is something should be done using a external software using github/gitlab

using hooks my sound good idea but only if you keep those hooks in your pc.