How to deploy site from GitHub on Netlify

beginner 8 min read Updated 2026-03-13
Quick Answer

Connect your GitHub repo to Netlify via the dashboard (New site from Git → GitHub), authorize access, select the repo/branch, specify build command (e.g., <code>npm run build</code>), publish directory (e.g., <code>dist</code>), then trigger deploy. Netlify clones the repo, installs dependencies, runs the build, and publishes with automatic deploys on future Git pushes.

Prerequisites

  • GitHub account with a public or private repository containing your site code
  • Netlify account (free tier works for most users)
  • Locally working build: run <code>npm run build</code> (or equivalent) successfully
  • Committed lockfile like <code>package-lock.json</code> or <code>yarn.lock</code>

Step-by-Step Instructions

1

Log in to Netlify and add new site

Go to app.netlify.com and sign in with your account. From the Sites dashboard (main overview page listing your sites), click the "Add new site" button or "New site from Git" option in the top-right area.
2

Select GitHub as provider

On the "Choose your Git provider" screen, click the GitHub button (not GitLab or Bitbucket). This opens the GitHub authorization flow.
Netlify supports public and private repos.
3

Authorize Netlify on GitHub

GitHub will prompt you to authorize Netlify. Click "Authorize Netlify" (or "Authorize Application"). Review permissions if needed (Netlify requests repo access for deployment; tokens are not stored on Netlify servers). Confirm to grant access to your repos.
This is a one-time setup; the connection persists.
4

Select your GitHub repository

Back in Netlify, you'll see a list of your GitHub repositories. Choose the specific repo containing your site code. Click "Select repository" or the repo name to proceed.
5

Configure build and deploy settings

On the "Configure your new site" screen (or "Build settings" panel): Set Branch to deploy (defaults to main or master; change if needed). Enter Build command like npm run build (leave blank for static sites). Set Publish directory to dist or build (use . for root). Add Environment variables if needed. Click "Deploy site" at the bottom.
Test your build locally first to avoid deploy failures.
6

Wait for initial deploy

Netlify clones the repo, runs the build command (if set), and deploys. Monitor progress in the Deploys tab (under "Recent deploys" section on site dashboard). The site gets a random URL like random-name.netlify.app. Once complete (green checkmark), visit the live URL.
First deploy takes 2-5 minutes depending on dependencies.
7

Customize site settings

From the site dashboard: Go to Site settings > Build & deploy > Continuous deployment to edit branch, build command, or publish directory. Under Site settings General > Change site name, set a custom name (e.g., my-site) for my-site.netlify.app.
For advanced config, add <pre><code>[build] command = "npm run build" publish = "dist"</code></pre> to <code>netlify.toml</code> in repo root.
8

Verify continuous deployment

Push any commit to your selected branch (e.g., git push origin main). Netlify auto-detects, rebuilds, and deploys. Check Deploys page for logs, build times, and preview URLs for branches/PRs.
Preview deploys automatically create unique URLs for pull requests.

Common Issues & Troubleshooting

Dependency install failures (e.g., <code>npm install</code> errors, <code>Cannot find module</code>, <code>ERESOLVE</code>)

Check deploy log for errors. Ensure lockfile (<code>package-lock.json</code>, <code>yarn.lock</code>) is committed and matches your package manager. Delete <code>node_modules</code> and reinstall locally, then push.

Build command fails (non-zero exit code)

Verify <code>npm run build</code> works locally. Check deploy log for stack traces. Add missing dependencies to <code>package.json</code> or set correct <strong>Node version</strong> in Netlify build settings.

Wrong publish directory (404 errors or blank page)

Confirm build output folder (<code>dist</code>, <code>build</code>) matches <strong>Publish directory</strong> setting. Run <code>ls -la</code> after local build to verify.

Deploy stuck or timeout

Check <strong>Deploys</strong> log for memory/timeout issues. Increase Node memory with env var <code>NODE_OPTIONS=--max_old_space_size=4096</code> or upgrade to larger build instance in Site settings.

Private repo access denied

Re-authorize Netlify in GitHub settings. Ensure repo permissions granted during OAuth. Try disconnecting/reconnecting Git provider in Netlify Site settings > Build & deploy.