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