Mrweiner
Mrweiner

Reputation: 521

Disallow branches off of branch?

We've got three branches -- Master, Dev, and Test. All features get branched from Master to correspond with Jira tickets, allowing them to be easily merged one-by-one to Dev and Test. However, we just ran into an issue on Test where a merged feature caused a bunch of issues. It turns out that that feature branch was actually created off of Dev instead of Master. Obviously a better review process would have caught this (and it's great that we caught it before it made its way to Master), but ideally this case shouldn't even be possible.

Is it possible to set up something like a protected branch, but that only allows merging and not branching? That way we are only able to branch off of Master, but not off of Test or Dev?

Upvotes: 2

Views: 57

Answers (1)

Danilo Souza Morães
Danilo Souza Morães

Reputation: 1593

You could handle this during merge, by not allowing a merge to happen if any of the commit ids returned by git log Master..Dev is found in feature-branch using something like git branch --contains=...

I believe this will take a bit of scripting and finding the right hooks for your process, but it's possible to get to a solution that brings more safety to your deployments.

Upvotes: 1

Related Questions