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 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
mainbefore 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)
- Go to the repository
- Compare your branch with
main - Add a clear title and description
- 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:
- Make the requested edits
- Commit again
- 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.jsonconflicts). - You didnβt pull latest changes before pushing.
- You auto-formatted files differently (Prettier, ESLint).
β Conflict Tips
- Use
git statusto 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