Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git merging issue

Tags:

git

merge

gitlab

Following is the git flow that we are about to follow. But the problem is we have to restrict people from re basing the feature branch from the developer branch. We should only let people rebase their feature branch from the release branch. Restriction should be that when a user trying to merge a feature branch which is created from the developer branch or re based from the developer branch that merge should be rejected. Is that can be done? enter image description here

like image 639
Asiri Liyana Arachchi Avatar asked Apr 09 '26 03:04

Asiri Liyana Arachchi


1 Answers

Hope I understood your question. You are looking for a way to restrict developers from creating feature branches from develop.

Below code snippet will help you to identify parent branch of a feature branch. You may have to add this to server side git pre-receive hook script.

branch=`git rev-parse --abbrev-ref HEAD` 
parent_branch=`git show-branch -a 2>/dev/null | grep '\*' | grep -v "$branch" | head -n1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//'`
if $parent_branch="develop"; then
    echo "please use release as base branch"
    exit 1
fi 
like image 87
SnehalK Avatar answered Apr 10 '26 22:04

SnehalK



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!