[Support Guide] How can I disable automatic git deploys?

Last reviewed by Netlify Support staff: April 2024

Sometimes your projects may really benefit from automatic deploys, sometimes they won’t. For such sites, you can create them entirely as manual deploys or using Netlify’s CLI. If you want to turn off automatic deploys from git for a site that was linked with a repository, there are four easy options outlined here. You can choose the option that works best with your workflow.

  1. We have a feature called Locked Deploys that you can use to 'pin' a deploy on your production URL.

    To turn on the lock feature from your Deploys page, click the Stop auto publishing button.

That’s it! Netlify will no longer autopublish any deploys at your production URL.

However, deploys will still be built and will be available for you to preview and manually publish whenever you want. You can still see all of your deploys as usual on your Deploys page in our UI.

When you are ready to resume automatic deploys, just click the Start auto publishing button.

  1. If you no longer want to trigger deploys via git, you can remove the webhook created by Netlify from your repository's webhook settings at your git provider. This is the way all GitLab and BitBucket repos are configured, and some legacy GitHub sites as well. And as long as you don't remove our deploy key, you can then trigger a deploy some other way - for instance, by pushing the “Trigger deploy” button on the Deploys page in our UI, or via Build Hooks or via our API. Note that folks using the GitHub app won’t have this option!

    No deploy previews for pull requests are created when you deploy this way, FYI.

  2. Use GitHub checks to stop automatic deploys under certain conditions using the protected branches feature. This last option is what we use internally at Netlify. We set it up this way so we have a successful build, all of our tests finish, and we have a deploy preview to look at before merging. So if a check fails, you’ll see a red x and your site will not merge & deploy:

If you’ve never used GitHub checks before, GitHub has easy, step-by-step instructions on how to set them up.

Note: If you want to keep your Netlify site but permanently remove the link from your site to your git repo, you can do so from the UI by visiting Site settings > Build & deploy > Repository . Then click ‘Manage repository’ and select unlink repositories name.

There is an API endpoint to unlink the repo from the site, however. This means it is possible to unlink repos using the API without contacting the support team if you want to do it yourself. The Netlify CLI tool is a great way to call the API and it can be done using this below:

netlify api unlinkSiteRepo  --data '{ "site_id": "<site API ID goes here>" }'

Note, the angle brackets should not be included. Here is a real world example (without angle brackets):

netlify api unlinkSiteRepo  --data '{ "site_id": "1a997e22-11b7-44b7-945b-c062ef03c8bf" }'
3 Likes