Git Notes
Netlify is a cloud platform that automates the build and deployment of web applications directly from your GitHub repository. Every time you push code,...
Netlify is a cloud platform that automates the build and deployment of web applications directly from your GitHub repository. Every time you push code, Netlify automatically builds your site and publishes it to a global CDN. It offers features like deploy previews for pull requests, serverless functions, form handling, and automatic HTTPS — making it one of the most popular deployment platforms for modern web projects.
Why Netlify for GitHub Projects
Netlify excels at deploying frontend applications and static sites with a developer experience that feels almost magical:
- Automatic deploys on every push to your configured branch
- Deploy previews for every pull request — reviewers can test changes live
- Instant rollbacks to any previous deployment with one click
- Branch deploys for testing different environments
- Edge functions for serverless compute at the CDN level
- Free tier that covers most personal and small team projects
Connecting GitHub to Netlify
Step 1: Sign Up and Connect
- Go to app.netlify.com and sign up with your GitHub account
- Click "Add new site" → "Import an existing project"
- Select GitHub as your Git provider
- Authorize Netlify to access your repositories
- Choose the repository to deploy
Step 2: Configure Build Settings
Netlify auto-detects most frameworks, but you can configure manually:
| Branch to deploy | main |
| Build command | npm run build |
| Publish directory | dist (or build, out, .next) |
For common frameworks:
| Framework | Build Command | Publish Directory |
|---|---|---|
| React (CRA) | npm run build | build |
| Vite | npm run build | dist |
| Next.js (static) | next build && next export | out |
| Gatsby | gatsby build | public |
| Hugo | hugo | public |
| Astro | astro build | dist |
Step 3: Deploy
Click "Deploy site." Netlify clones your repo, runs the build command, and publishes the output. Your site is live within minutes at a random URL like amazing-hopper-abc123.netlify.app.
Configuring with netlify.toml
For reproducible configurations, add a netlify.toml file to your repository root:
Deploy Previews for Pull Requests
One of Netlify's best features is automatic deploy previews. When someone opens a pull request:
- Netlify builds the PR branch
- Deploys it to a unique URL (like
deploy-preview-42--your-site.netlify.app) - Posts a comment on the PR with the preview URL
- Reviewers can test the changes live before approving
This means code reviewers do not need to pull the branch locally and run it — they can simply click the link and see the result.
Environment Variables
Set environment variables in Netlify's dashboard or in netlify.toml:
For sensitive values (API keys, secrets), use the Netlify dashboard under Site settings → Environment variables. These are injected at build time but never committed to your repository.
Continuous Deployment Workflow
The typical workflow with Netlify:
# Developer works on feature
git checkout -b feature/contact-form
# ... make changes ...
git push origin feature/contact-form
# Netlify builds a deploy preview automatically
# Open PR on GitHub — preview URL appears in PR comments
# After review and merge to main
git checkout main
git merge feature/contact-form
git push origin main
# Netlify automatically deploys to productionCustom Domains
- Go to Site settings → Domain management
- Add your custom domain
- Configure DNS:
| Type | CNAME |
| Name | www |
| Value | your-site.netlify.app |
| Type | A |
| Name | @ |
| Value | 75.2.60.5 |
Netlify provisions and renews SSL certificates automatically.
Rollbacks and Deploy Locks
Instant rollback: Every deployment is immutable. Go to Deploys → click any previous deploy → "Publish deploy." Your site instantly reverts to that version.
Deploy locks: Lock your production site to prevent automatic deployments during sensitive periods:
# Using Netlify CLI
netlify deploy --lock
# Make manual changes or fixes
netlify deploy --unlockServerless Functions
Add backend functionality without a server:
Access at /.netlify/functions/hello. These functions scale automatically and are perfect for API endpoints, form processing, and third-party integrations.
Key Takeaways
Netlify transforms GitHub repositories into live websites with zero server management. Its deploy preview feature revolutionizes code review by letting reviewers see changes live. Combined with serverless functions, custom domains, and automatic HTTPS, Netlify provides a complete deployment platform that scales from personal projects to production applications — all triggered by simply pushing to your GitHub repository.
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Netlify Deployment from GitHub.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Git & GitHub topic.
Search Terms
git-github, git & github, git, github, deployment, netlify, from, netlify deployment from github
Related Git & GitHub Topics