Take control with branch restrictions

By on September 16, 2013

With Git, branching has never been easier — especially with the introduction of amazing new workflow capabilities such as git-flow. Some development workflows require that specific developers oversee merges into the master or release branches, while other developers work on bug-fix and feature branches.

Bitbucket’s latest feature, branch restrictions, lets you turn this “gentlemen’s agreement” into a seamless, enforceable process, reducing confusion and time wasted backing out changes that were merged prematurely.

Enforce your workflows

At the heart of branch restrictions is a new repository write permission that allows you to control who can commit to specific branches in a repository. Branch permissions are set on a per-repository basis by specifying a user or group who already has access to a given repository.

Bitbucket Branch restrictions

Restrictions are based on explicit branch names, or you can use advanced branch permissions to match multiple branches (or tags) using pattern matching. For example, use an * (asterisk) in a rule: “f*r” matches foobar and footer. Establishing naming conventions based on roles or functional area (e.g., “contractor_” or “userauth_”) makes it even easier to set and standardize permissions throughout your organization.

Edit-undo becomes a thing of the past

Simplify your Git repository management

Bitbucket is free individuals and teams of five or less, and includes unlimited repositories. Start a free trial today and get up and running in a matter of minutes!

Create a free account


  • henry
    Posted September 17, 2013 at 12:00 am | Permalink

    Is this just for git?

    • Egor
      Posted September 17, 2013 at 1:22 am | Permalink

      +1, really want to see this for mercurial.

      • Lehóczky Zoltán
        Posted September 17, 2013 at 2:10 am | Permalink

        This works for mercurial too! For the prevention of deleting certain branches for mercurial it’s the same with bookmarks.

        • Egor
          Posted September 17, 2013 at 3:26 am | Permalink

          Awesome, thanks!

  • mrts
    Posted September 19, 2013 at 3:00 am | Permalink

    Love it, helps devs not to shoot themselves into foot! Thanks!

  • Martin Geisler
    Posted October 1, 2013 at 1:46 pm | Permalink

    I’m disappointed to see the blog post starting like this “With Git, branching has never been easier” when you know very well that Mercurial also allows easy branching! The feature even works for Mercurial, so please have the courtesy of promoting both systems equally.

    • AngelEzquerra
      Posted October 1, 2013 at 9:40 pm | Permalink

      I agree. Both got and mercurial make it very easy to branch your code. If the feature works with both DVCSs, why Melvin one but not the other?

    • jkirkby
      Posted September 22, 2015 at 8:50 am | Permalink

      yes mercurial has branching but the article says “With Git, branching has never been easier” mercurials method of branching and pulling /updating the branch is stupid. why do i need to run a separate command to update that branch when i already told it to pull??

  • Anonymous
    Posted June 10, 2014 at 7:53 am | Permalink

    How does one get this to work with tags? Mentioned, “match multiple branches (or tags) using pattern matching” but so far nothing has worked. Even * rule doesn’t prevent tags from being pushed. Have also tried refs/tags/* and */tags/*.

    • lung220
      Posted September 27, 2016 at 1:32 pm | Permalink

      Has there been update regarding the tag permissions issue? It has been 2 years by now, still it doesn’t seem to work to restrict pushing or deleting tags.

  • Art Vandelay
    Posted June 13, 2016 at 7:26 pm | Permalink

    Is there a way to enforce a code freeze in a branch?

    • Raj Sarkar
      Posted June 14, 2016 at 2:13 pm | Permalink

      you could limit pushes on a branch to just to the lead or release manager, which would effectively enforce a freeze