Netlify error fetching branch

If you have a website on Netlify using hugo, you may met a build error which says “Error fetching branch https:xxx/xxx” problem.

8:17:03 PM: Build ready to start
8:17:05 PM: build-image version: d4c1cbd181c77e86d1a1ea811f472d1eb6ecb0c9181ca811
8:17:05 PM: build-image tag: v3.3.20
8:17:05 PM: buildbot version: 4de2ccbbe16fa4301cc32af86cbbe8e65c121cf4
8:17:06 PM: Fetching cached dependencies
8:17:06 PM: Starting to download cache of 238.5MB
8:17:13 PM: Finished downloading cache in 7.16924154s
8:17:13 PM: Starting to extract cache
8:17:22 PM: Finished extracting cache in 8.982486036s
8:17:22 PM: Finished fetching cache in 16.214185918s
8:17:22 PM: Starting to prepare the repo for build
8:17:22 PM: Preparing Git Reference refs/heads/master
8:17:24 PM: Error fetching branch: https://xxx/xxx/xxx refs/heads/master
8:17:24 PM: Failing build: Failed to prepare repo
8:17:24 PM: Failed during stage 'preparing repo': exit status 1
8:17:24 PM: Finished processing build request in 18.511766181s

Try to Clear cache and deploy site rather than Deploy site.

If this time the build successes, the problem should be there’s something wrong with the cache, therefore cleared cache before deploy site solves the issue.

If the build log says Fetched in submodule path 'themes/xxx', but it did not contain like below, then the reason is that you forget to push the submodule before you push the main branch. Just push the submodule and try again. And do not forget this step if you have changed and committed the submodule in the future .

9:11:22 PM: Error checking out submodules: Submodule 'themes/my-theme' (https://github.com/ling091/hugo-my-theme.git) registered for path 'themes/my-theme'
Cloning into '/opt/build/repo/themes/my-theme'...
fatal: remote error: upload-pack: not our ref 00a08cebd6d04e99b15eb3c47dcdd386a1634650
fatal: the remote end hung up unexpectedly
Fetched in submodule path 'themes/my-theme', but it did not contain 00a08cebd6d04e99b15eb3c47dcdd386a1634650. Direct fetching of that commit failed.
4:23:30 PM: Failing build: Failed to prepare repo
4:23:30 PM: Failed during stage 'preparing repo': Error checking out submodules: Submodule 'themes/my-theme' (https://github.com/ling091/hugo-my-theme.git) registered for path 'themes/my-theme'
Cloning into '/opt/build/repo/themes/my-theme'...
fatal: remote error: upload-pack: not our ref 00a08cebd6d04e99b15eb3c47dcdd386a1634650
fatal: the remote end hung up unexpectedly
Fetched in submodule path 'themes/my-theme', but it did not contain 00a08cebd6d04e99b15eb3c47dcdd386a1634650. Direct fetching of that commit failed.
: exit status 1
4:23:30 PM: Finished processing build request in 3.587139141s

If the issue stays the same, try to clone your repo manually in a terminal. Make sure that your repo are ready to be cloned without any trouble.

August 2, 2020 netlify

Why you should use a static generator for building websites

Static site generators have been popular over the past few years. Static sites bring many advantages especially when it comes to speed and security. The pages pre-rendered by generators can be served just over a CDN. That saves a lot of effort and money for running a server. And today's generators have been capable to meet some dynamic requirements, such as comments, real-time data updating, etc.

netlify static-site-generator