How to delete branch deploy?

Currently there is not a way to delete a deploy.

1 Like

Thanks for your feedback. That’s not … confortable i would say.

Oh no, not sensible (got lucky thought, a warning would be great) but really not UX friendly I would say, not having the control on what you want or not to be published.

Even on Netlify side I think that would be great not to have VM’s hanging around for people who don’t need them.

Hey Matt,

The challenge is the way Netlify stores files - files’ contents are indexed/attached directly to the deploy object for the first deploy we see them in. And they are not “re-stored” with later deploys in our backing store. You can see we wouldn’t want to keep a zillion copies of jquery.js around, right?

So, we really can’t remove deploys and ensure that your site will continue to work. Your best bet if you want to make sure it’s gone is to delete the site and recreate it. And FYI, we don’t use a per-site VM or really any single-site resources in our network architecture - for serving content we use a general cache that all of our sites share so there are no additional “resources” used in that cache by having old deploys around - it won’t be in the cache, unless people are repeatedly fetching that content (using the deploy-specific URL). So if it’s in cache then…well, it is being used and being served faster than if we had to repopulate the cache from our database again :slight_smile:

But…most people don’t express a desire to delete deploys in the first place, so we haven’t really considered changing the feature before. Could you elaborate on your use case in wanting to remove it?


Thanks for your feedback.
Yes, I do believe it is quite a challenge to run a service like Netlify, no question.

Just to give you my usecase last week :

  • Had an issue with a third party js lib
  • Report issue to lib maintainer who asked to see the problem “live”
  • “No problem I use Netlify” : Made a branch from master (“tocbot”) and use branch-deploy
  • Send the branch deploy url to maintainer, who found the problem and closed issue
  • I deleted my branch (no merge)
  • I looked around to delete my deploy, the one from the branch (not the master), impossible.

As a user experience, my 2 cts :

  • I can create a Netlify account and I can delete this account. I am in control. Good UX.
  • I can deploy a site, I can delete this site, I feel in control of what I publish on the internet. Perfect.
  • I can deploy a branch but I cannot delete this branch. I am not in control (bad UX pattern in my personal opinion). I haven’t been warned I couldn’t delete it.
  • In my view and workflow, a branch is temporary, during a lifecycle of a feature before a merge into master. A branch-deploy, I assumed initially, would have had the same behavior.

Some concerns that come to my mind :
What if I publish, by mistake, some sensible information ? I have to delete the whole site and recreate ?
What if, over the span of several month/years I published 50 branches ? I have 50 copies of my website on the internet ?
I have read that Netlify add a “no-index” header to those deploys but if Netlify make a mistake one day (everybody does) and I have suddenly 50 websites that Google considers as duplicate ? Sandbox. Really not great.

Please note
I discovered recently Netlify and I think it is great. Simple and straight to point (a blessing in the SSG exploding market)
This branch (or PR) deploy is a great feature, a great idea, really useful. But I wouldn’t use it anymore now knowing I cannot delete these “drafts”



Since we can’t delete a deploy, here is a way to alleviate the case you don’t want to have the branch deploys.

Branch for preview (temporarily)

  • Set your production site with no previews and branch deploys under Continuous Deployment
  • Set up a [new site] to the same repo and build the branch
  • Delete the [new site] when no longer needed
  • Rinse and repeat

Yes, I was thinking about testing this approach in the end. My only concern (I have to test) is that it forces us to update the dns for the subdomain (CNAME pointing to a random Netlify ID that will change with the new website)

You don’t even need to set DNS up - you could always use the netlify sitename (which you can also change to be something consistent like for each site you set up and then delete in sequence).

If you use Netlify’s DNS hosting, we’ll also automatically “do the right thing” for records like that and remove and recreate them for you to be correct.

1 Like

I’ll try that, thanks


I’m facing the same problem,
I Just deleted the branch in bitbucket and still sub domain exist !!
and also tried to delete it’s DNS Records but it didn’t work “This is a system record that cannot be managed directly.”

Hi @Miggz. Welcome to our community!

Support can delete Netlify-created DNS records for you. Let us know the name of the site and the name of the record and we can take care of it. If you’re not comfortable posting that here, please mention that, and we’ll DM you.

1 Like

If we still can’t delete deployments could at least unpublish a branch URL so it is not available?

I’ve be using a preview deploy but there appears to be issues with the role based gating not on main deploy. I want to stop anyone using the branch so they only have main available

I’d rather not start a new project but if that’s the only way…

cc @jonsully

1 Like

That is the only way, Slim. Branch subdomains, are directly tied to deploys, and you can’t remove either without totally starting over.

Sorry I don’t have better news for you today.

1 Like

@fool I went ahead a did it. It was relatively painless. I just had to enable the services like identity and copy my env vars.

Plus I totally love the new random URI of “festive hoover” :stuck_out_tongue:

:smiley: Sometimes our name generator is brilliant. And sometimes it is very stupid :slight_smile:

Glad to hear you got this resolved!

1 Like

Hi there,

Just to confirm: When we create a branch deploy or deploy preview, we can never take the site down that’s created by that? That branch will always be viewable and accessible at that site URL?

Hey @PopInnovate, yes, that is correct :+1:

Hi Jen,

I have a use case that I believe will likely effect others. All our past Deploy Previews have been indexed by search engines. Since discovering this we have updated our build config to write a Disallow robots.txt for the deploy-preview and branch-preview build contexts.
But every other deploy preview created before this change is still crawled and accessed, appearing in search results and thus diverting traffic from our production site.

Can you step us through your recommended approach to resolving this?

Thank you

Hey @digeverything,
That… should not be happening! Could you please share your Netlify url with us so we can take a look?

Hi Jen can I move this into a DM with you?