guide
Learn the complete Git workflow used by professional developers for Next.js projects. Understand Git branching, GitHub integration, and automatic Vercel deployments from development to production.

When building modern applications like a Next.js portfolio, SaaS product, or ecommerce app, writing code is only half of the job.
The other half is managing code safely.
Without proper version control you can easily:
This is exactly why Git exists.
Git allows developers to track every change in their project and safely experiment with new features without risking the main application.
Combined with GitHub and Vercel, it creates a powerful workflow used by professional developers.
This guide will walk you through the real-world workflow developers use when building and deploying modern applications.
We will cover:
By the end of this guide you will understand the complete development lifecycle.
First create your project locally.
npx create-next-app@latest my-portfolioMove into the project directory:
cd my-portfolioStart the development server:
npm run devNow your project runs at:
http://localhost:3000
Your project structure will look something like this:
my-portfolio
├─ app
├─ components
├─ public
├─ package.json
└─ next.config.js
At this stage you can start building your application:
Once the project works locally, it's time to add version control.
Inside your project folder run:
git initThis command creates a Git repository.
Git will now track all changes made in this project.
Next add all files to Git:
git add .Now create your first commit:
git commit -m "Initial portfolio setup"A commit is basically a snapshot of your project at a specific moment.
Now we store the project in the cloud.
Go to GitHub and click:
New Repository
Example settings:
Repository name: portfolio
Visibility: public
Important:
Do NOT initialize with README if your project already exists locally.
After creating the repository, GitHub will show commands like this.
Run these commands in your terminal:
git remote add origin https://github.com/username/portfolio.git
git branch -M main
git push -u origin mainNow your code is stored on GitHub.
Benefits of this step:
Now we deploy the application.
Go to Vercel and click:
Add New Project
Then select:
Import Git Repository
Choose your GitHub repository.
Vercel will automatically detect:
Framework: Next.js
Click Deploy.
After about 30 seconds your site will be live at something like:
https://portfolio.vercel.app
Congratulations — your app is now live on the internet.
The workflow now becomes very simple.
Local Code
↓
Git Commit
↓
GitHub Repository
↓
Vercel Deployment
↓
Live Website
Whenever you push code to GitHub, Vercel automatically redeploys the app.
Example:
git add .
git commit -m "added projects section"
git pushVercel will detect the change and rebuild the site.
Professional developers never experiment in the main branch.
Why?
Because the main branch represents production code.
If you break it, your live website breaks.
Instead developers create feature branches.
Example: you want to add a dashboard.
Create a branch:
git checkout -b feature-dashboardNow Git switches to a new branch.
Important:
You are still working in the same project folder in VS Code.
You do NOT create another project.
You simply add new files.
Example:
app/dashboard/page.tsx
app/dashboard/profile/page.tsx
app/dashboard/settings/page.tsx
Run the app locally:
npm run devOpen:
http://localhost:3000/dashboard
Now you can develop safely.
When your feature is ready:
git add .
git commit -m "add dashboard layout"Push the branch to GitHub:
git push origin feature-dashboardNow the feature branch exists on GitHub.
One of Vercel's most powerful features is preview deployments.
Every branch gets its own preview environment.
Example:
feature-dashboard.vercel.app
This means you can test new features online without affecting the main website.
Your production site remains unchanged.
If the feature works well, merge it into the main branch.
First switch to main:
git checkout mainThen merge:
git merge feature-dashboardFinally push the update:
git pushNow the workflow looks like this:
GitHub main updated
↓
Vercel rebuilds
↓
Live website updated
Once the feature is merged, you can delete the branch.
git branch -D feature-dashboardTo delete it from GitHub:
git push origin --delete feature-dashboardThis keeps your repository clean.
Sometimes new code introduces bugs.
Git makes it easy to revert.
Check your commit history:
git logExample:
commit1 initial setup
commit2 projects page
commit3 blog page
commit4 dashboard
If the dashboard broke the app you can restore the previous version.
git reset --hard commit3
git push --forceYour project instantly returns to a working state.
Large projects usually use a branching structure like this:
main → production
dev → testing
feature-dashboard
feature-auth
feature-comments
feature-dark-mode
Workflow:
feature → dev → main
Benefits:
A typical development day looks like this.
Pull latest code:
git pullCreate a new feature branch:
git checkout -b feature-blog-commentsAdd your code.
Commit changes:
git commit -m "add blog comments"Push branch:
git push origin feature-blog-commentsTest preview deployment on Vercel.
If everything works → merge to main.
Modern web development relies heavily on Git workflows.
Important principles to remember:
Following this workflow keeps your applications stable, scalable, and professional.
Learning Git properly is one of the most valuable skills for any developer. It allows you to:
Once you adopt this workflow, building and maintaining applications becomes dramatically easier.
And this is exactly the workflow used by developers building real production systems every day.
I share new articles, insights, and experiments in modern web development. No spam — just useful content.