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.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay