Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

netlify deploy failed: git ref refs/heads/master does not exist or you do not have permission

I ran into a bigger problem and am really desperate and downturned because I cannot figure out a solution.

I am using a Notebook with Linux Debian 9, git for version control, bitbucket as source code repository service and netlify as production deployment service. Besides I am using Contentful CMS API to quickly add new pages.

Yesterday I deleted my repository on bitbucket and pushed the same one with some slight changes freshly from my local "backup" repo to bitbucket today.

Pushing is just working fine. However, I cannot deploy with Netlify anymore... I keep getting the following error:

10:21:02 PM: Starting to prepare the repo for build 10:21:05 PM: git ref refs/heads/master does not exist or you do not have permission 10:21:05 PM: Failing build: Failed to prepare repo 10:21:05 PM: failed during stage 'preparing repo': git ref refs/heads/master does not exist 10:21:05 PM: Finished processing build request in 12.473521036s

When I push, Netlify tries to build, so there is a connection between Bitbucket and Netlify but the build fails. In my local repo refs/heads/master does exist. git branch -a also tells me that my branch is master. On bitbucket the branch is also master.

Why won't Netlify build? Is there a problem with the API ID? The API ID might only be valid for the repo I deleted yesterday but then Netlify and Bitbucket wouldn't be able to communicate, right?

I didn't make any changes in Netlify. The only thing I changed is the Repository on Bitbucket. I am assuming that I broke the API ID. I cannot change the API on Netlify, though. Also, there doesn't seem to be any option on Bitbucket for adding it.

And I don't even know if that is the problem. If it is, the only 2 options I have got is deleting the Netlify website and create a new one, choosing the bitbucket repo and granting Netlify full access to it.

But what happens if it won't deploy? Then it is offline and I won't be able to bring it up again.

Can anyone help me? What am I supposed to do? Let me know if you need any additional information.

like image 912
timunix Avatar asked Dec 07 '18 21:12

timunix


People also ask

How do I authorize Netlify?

Do the following to enable Identity service on your site. In the Netlify UI, navigate to your site. Select the Identity tab. Select Enable Identity.

How do I link my GitHub to Netlify?

Link a Git repository You can link a site to a Git repository in the Netlify UI. To do so, go to Site settings > Build & deploy > Continuous deployment > Repository and select Link repository. Alternatively, you can link a site to a Git repository with the Netlify CLI.

Can Netlify use private GitHub repo?

On Netlify, anyone can set up automatic deploys from: personal public repositories. personal private repositories. organization-owned public repositories.

Does Netlify support BitBucket?

Netlify CMS 2.0 launches with BitBucket support and a new monorepo architecture. Subscribe to our newsletter to make sure you don't miss anything.


1 Answers

Try the following:

  • Go to Netlify and choose the existing site
  • Click on Settings
  • In the left menu select Build and Deploy
  • Under Deploy Settings click on the Edit Settings button
  • Then next to Repository, click on Link to a different repository enter image description here
  • Select Bitbucket and the new repository

This should update your API ID for the new Repository. You may need to manually trigger a deploy after this step.

like image 71
talves Avatar answered Oct 09 '22 09:10

talves