🔹 Steps to Deploy Code Changes in a Team
- Create a Feature Branch
- Never commit directly to
main/master. -
Example:
git checkout -b feature/add-login
- Never commit directly to
- Make Code Changes
- Implement your feature or bug fix in the branch.
-
Stage and commit changes:
git add . git commit -m "Added login feature with JWT authentication"
- Push to Remote Repository
-
Push your branch to GitHub/GitLab/Bitbucket:
git push origin feature/add-login
-
- Create a Pull Request (PR) / Merge Request (MR)
- Open a PR on the remote repo (e.g., GitHub).
- Team members review code, suggest changes, and approve.
- Code quality checks run (Linting, Unit tests, CI/CD pipeline).
- Code Review & Merge
- After approval, merge the PR into
mainordevelopbranch. - Example merge strategy:
- Squash merge → keeps history clean.
- Rebase and merge → linear history.
- After approval, merge the PR into
- CI/CD Pipeline Runs
- Once merged, CI/CD tools (Jenkins, GitHub Actions, GitLab CI, CircleCI, etc.) automatically:
- Run tests ✅
- Build code 📦
- Deploy to staging/production 🚀
- Once merged, CI/CD tools (Jenkins, GitHub Actions, GitLab CI, CircleCI, etc.) automatically:
- Deployment
- Code is deployed to:
- Staging environment → test with real data.
- Production environment → final users see changes.
- Code is deployed to:
🔹 Example with GitHub + Vercel (MERN App)
- Step 1: Work on branch
feature/ui-fix. - Step 2: Push code → create PR on GitHub.
- Step 3: GitHub Actions run tests automatically.
- Step 4: After approval, PR merged to
main. - Step 5: Vercel detects new commit on
mainand auto-deploys app to production.
🔹 Key Best Practices
- Always work on feature branches.
- Ensure PR reviews before merging.
- Use CI/CD pipeline for automation (tests, builds, deploys).
- Deploy to staging first, then production.
- Write clear commit messages.
✅ Answer in Interview (Short):
“In a team, I work on a separate feature branch, push my changes, and create a pull request for review. After approval, the code is merged into the main branch. Our CI/CD pipeline automatically runs tests and deploys the changes to staging or production. This ensures code quality, collaboration, and smooth deployments.”