Enforcing branch names using Stash/Sourcetree and the Branching Model.

We are quite new to GIT/Stash but so far it's all going very well. We have out workflow and branching model defined.

Today we enabled the Branching model in Stash, and the expectation is, that Sourcetree/GIT would reject branch names that don't conform to this pattern if developers tried to push them. This doesn't seem to be the case. Developers can create branches without a prefix or with some other prefix. Have I mis-understood something?

Our branching model looks like this:

Branching Model

2 answers

1 votes
Timothy Chin Community Champion Mar 04, 2014

The branching model in essense is just a model/template to use. It is not enforcable without add ons in Stash (https://developer.atlassian.com/stash/docs/latest/how-tos/responding-to-application-events.html).

The wording by Atlassian suggests that it enforces it..

  • "guide your developers into making consistent naming decisions when creating branches."

It's not really doing anything active at all. Infact since switching it on, we havn't really noticed any differences. I guess the change only applies if you create branches from Stash or JIRA. Is this the point of it?

Roger Barnes Atlassian Team Mar 05, 2014

Hi Mark,

Tim is correct, currently the branch model is not enforced, but it can be by way of add-ons.

For now this means that the current out-of-the-box experience is that people using create branch from within JIRA and Stash will get the benefit of a branch model's guidance, but no one is prevented from naming new branches however they like.

Encouraging a social standard seems to work quite well for many, but I can appreciate that some projects need more restrictive flows (even in a distributed world). We are open to suggestions on where we can take workflow automation and management in the future in a way that works for most teams.

Is there an already existing add-on which can do this?

Your branching model is called "Git Flow" is SourceTree. SourceTree will not import the settings from Stash, but the first time a developer hits the "Git Flow" button, they will be asked to enter the same thing.

After the first time, you can the branching model can be enforced IF your devs only create branches with the Git Flow button. Doing so when development is checked out will ask if they are creating a feature, hotfix, or release, and will automatically prepend the selected prefix to whatever name they choose for the new branch. Hitting Git Flow while in a feature, hotfix, or release branch will prompt the user to "finish", which merge that branch into the appropriate other branches (develop for feature, develop and master for hotfix and release).

After looking over your screenshot once more, it is worth pointing out that Git Flow doesn't support a "bugfix" branch.

We aren't using Gitflow, We started out down that route, but it's not really correct for us.

We now instruct developers to use the Branch and Merge buttons NOT the GitFlow one. However nothing actually guides them into making the right branch names...

In the end, we have shown them how easy it is to create the branch directly from JIRA (with the Stash Integration), they now all use that, so the branching naming isn't so much of a big deal anymore.

I'm sure there will always be one smartass that wants to do something different however, like create their branches using GIT CLI.....

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

675 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot