Go to all posts

Git Workflow for Junior Developers

Dipesh Aryal/June 15, 2025

A detailed step-by-step Git workflow guide with best practices, from cloning to handling PR reviews and merge conflicts.

Git Logo

Git Workflow for Junior Developers πŸš€

As I was learning git and github I made some notes and created this guide from the notes so that if anyone needs it they can refer to it

This guide outlines the real-world Git workflow you’ll follow as a junior dev working in teams. It starts from cloning a repo, and covers day-to-day practices, including pulling, rebasing, committing, handling rejected pull requests, and avoiding merge conflicts.

🧭 Step 1: Clone the Project

git clone https://github.com/org/project-name.git
cd project-name

πŸ” Make sure you're in the correct working directory (cd project-name).

🌱 Step 2: Start From a Fresh main Branch

git checkout main
git pull origin main

βœ… Always pull the latest main before starting new work. This avoids surprises later.

🌿 Step 3: Create a Feature Branch

git checkout -b feat/user-login

✍️ Naming Convention:

  • feat/ β†’ new feature (feat/navbar)
  • fix/ β†’ bug fix (fix/form-validation)
  • refactor/ β†’ cleanups (refactor/home-component)
  • chore/ β†’ config or minor updates

πŸ’» Step 4: Work Locally & Commit Often

git add .
git commit -m "Add login form UI with basic validation"

βœ… Commit Best Practices

  • Write clear, atomic commits (small, focused)
  • Use present tense: "Add X", not "Added X"
  • Avoid meaningless messages: Update, Fix stuff

πŸ“Œ Commit frequency: After every small, testable milestone β€” even if it’s just styling or a hook.

πŸ” Step 5: Rebase Before You Push

Before pushing, rebase your feature branch with the latest main to prevent conflicts and keep a clean history.

git pull origin main --rebase

πŸ”„ Why not merge? Rebase avoids cluttered commit history full of merge commits.

πŸš€ Step 6: Push to Remote

git push origin feat/user-login

Then go to GitHub/GitLab and open a Pull Request.

πŸ“‹ Step 7: Open a Pull Request (PR)

  1. Go to the repository
  2. Compare your branch with main
  3. Add a clear title and description
  4. Tag reviewers (your team lead or senior dev)

βœ… Describe what the PR does, and how to test it if needed.

❌ Step 8: Rejected PR? Handle Gracefully

If your PR is rejected or needs changes:

  1. Make the requested edits
  2. Commit again
  3. Push again β€” the PR will update automatically
git add .
git commit -m "Fix: change form validation as per review"
git push

πŸ” Don’t take PR reviews personally β€” they’re about improving code, not criticizing you.

πŸ”€ Step 9: Merge & Cleanup

Once approved and merged (by you or a team member):

git checkout main
git pull origin main
git branch -d feat/user-login
git push origin --delete feat/user-login

🧹 Clean up local and remote branches to keep the repo tidy.

⚠️ Common Merge Conflict Triggers

  • You and another dev edited the same line in a file.
  • You both added different packages at the same time (causing package-lock.json conflicts).
  • You didn’t pull latest changes before pushing.
  • You auto-formatted files differently (Prettier, ESLint).

βœ… Conflict Tips

  • Use git status to see which files are conflicted
  • Resolve manually or using VS Code
  • After resolving:
git add .
git rebase --continue

πŸ›  Tools That Help

  • VS Code Git UI β€” for staging, commits, conflict resolution
  • GitLens extension β€” shows who changed what
  • GitHub Desktop / GitKraken β€” visual Git clients (optional)
  • Husky + Lint-Staged β€” run Prettier/linter before commits

🏁 Final Thoughts

Learning Git deeply takes time, but this workflow will help you:

  • Collaborate effectively
  • Avoid conflicts and messy history
  • Grow faster as a team-oriented developer