DEV Community

loading...

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

boyukbas profile image baris ・1 min read

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

Discussion (1)

pic
Editor guide
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.