Issues with reserved branch keywords

I would like to deploy my “dev” branch using a specific set of environment variables.

But when I try configuring a variable for the “dev” branch specifically, I am met with the following message:

dev is a reserved branch kevword (these include: production, deploy-preview, branch-deploy, dev, branch, main, master)

I’m sure there are good reasons for this limitation but wouldn’t it make sense being able publish these branches using different environment variables?

Currently all branches use the same “Branch deploys” value, which means all of them are hitting the same backend instead of their specific backend deployments.

Off the top of my head I see two solutions:

I could rename the branch, which defeats the purpose of reserving its name in the first place, since “dev” wouldn’t exist in the first place. This also means that Netlify is dictating my branching strategy which doesn’t feel right to me since it could (and does) influence many other aspects of the CI/CD pipeline.

Or I could create a dedicated Netlify site that deploys a specific branch as the production branch which defeats the purpose of having environment variables for different branches/contexts. It also means that I can’t make use of shared variables which is an awesome feature.

What is the best practice here?

1 Like

Unfortunately, the best practice for your success today will indeed be not to use a branch named dev, (or one named “production”, “deploy-preview”, “branch-deploy”, or “branch”).

This is the first time I’ve heard of someone running into this and I do agree your usage is not super weird, so might I suggest filing a bug report here? Issues · netlify/cli · GitHub


I have the exact same problem.

OK. I’d suggest actually filing the bug that the person who initially reported this did not, so that our staff can review & decide if they’ll work on it or not. You can do so here:

As far as I can tell, you two are the only folks who’ve ever run into this, so we haven’t decided to do any work to enable the use case, but hard to be sure without that issue filed :slight_smile:

I am a new user, migrating from Gatsby Cloud, and I just searched for “reserved branch keywords” and this thread was the only result. I am having the same problem the other users were having, but honestly I do not understand how thousands of people aren’t having this same issue (which makes me think maybe I am missing something).

We host our repos on BitBucket, and the branches we are interested in deploying from are mostly named after their role - ‘production’ for production, ‘development’ for development. We also utilize ‘master’ or ‘main’ to deploy to a stage environment (and when we’re ready, we then merge ‘master’ into ‘production’). I am unable to create any custom environment variable customizations for branches named ‘master’ or ‘main’ because of the reserved branch keywords issue.

Is this to be expected? Are our branch naming conventions so atypical that I’m only the 3rd person ever to inquire about this in the forums?

1 Like

We (Limber Health) are a pro account and have the exact same problem. @fool it seems you understand the use case and the problem. Can you create the bug report yourself? I don’t have a GitHub work account. (we use Gitlab)

I just submitted a feature request, asking for the list be to revisited here, let’s hope something comes of it.

In the end I opted to simply rename my branches as I had more pressing matters to think about.