DEV Community

Vincent Tommi
Vincent Tommi

Posted on

How to Work on a Team with Git & GitHub Without Breaking Everything

The Definitive Guide Every Engineering Team Should Adopt

  • Stop fighting over Git.
  • Stop breaking main.
  • Stop losing work. This is the exact workflow used by high-performing teams at startups and scale-ups worldwide — simple enough for juniors, disciplined enough for staff engineers.

The Core Workflow (6 Commands to Rule Them All)

# 1. Safely stash your in-progress changes
git stash push -m "wip: halfway through payment UI"

# 2. Fetch and integrate the latest main
git pull origin main --rebase    # preferred over merge for clean history

# 3. Re-apply your work on top
git stash pop                    # resolves conflicts early

# 4. Stage changes
git add .

# 5. Write a meaningful commit message
git commit -m "feat: add real-time donation progress bar with percentage"

# 6. Push to remote
git push origin HEAD
Enter fullscreen mode Exit fullscreen mode

Daily & Hourly Discipline (Do This Religiously)

git stash
git pull origin main --rebase
git stash pop
Enter fullscreen mode Exit fullscreen mode

Do this:

  • First thing in the morning
  • Before starting any new task
  • After a teammate announces a hotfix
  • Before pushing any commit

This single habit eliminates 95% of merge conflicts

Pro-Level One-Liner (Add to Your Shell)

# ~/.zshrc or ~/.bash_profile
alias sync="git stash push -m 'autosave $(date +%H:%M)' \
    && git pull origin main --rebase \
    && git stash pop"
Enter fullscreen mode Exit fullscreen mode

Now just run:

sync
Enter fullscreen mode Exit fullscreen mode

Recommended Branching Strategy (Safe + Fast)

Task Type Branch Name Example Workflow
Hotfix / Urgent hotfix/double-payment Direct to main (with PR)
Feature (>1 hour) feat/donation-progress-bar Branch → PR → Review → Merge
Bugfix fix/invalid-goal-calculation Branch → PR
Refactor / Chore refactor/extract-payment-service Branch → PR
# Example: Start a proper feature branch
git pull origin main --rebase
git checkout -b feat/share-fundraiser-buttons
# ... work ...
git add .
git commit -m "feat: add social sharing for fundraisers"
git push -u origin feat/share-fundraiser-buttons
# → Open Pull Request on GitHub
Enter fullscreen mode Exit fullscreen mode

Conventional Commits (Your Team Will Thank You)
Always use this format — enables auto-changelogs and clear history:

feat:     Add new feature
fix:      Bug fix
docs:     Documentation only changes
style:    Formatting, missing semicolons, etc.
refactor: Code change that neither fixes a bug nor adds a feature
perf:     Performance improvements
test:     Adding or correcting tests
chore:    Build process or auxiliary tool changes
Enter fullscreen mode Exit fullscreen mode

Examples:

git commit -m "feat: add fundraiser short link sharing"
git commit -m "fix: prevent negative donation amounts"
git commit -m "refactor: extract donation validation logic"
Enter fullscreen mode Exit fullscreen mode

Conflict Resolution (When stash pop Fails)

git stash pop
# → Conflict in payments/views.py

# Fix the <<< === >>> markers manually
# Then:
git add payments/views.py
git commit  # no -m needed, Git creates merge commit message
Enter fullscreen mode Exit fullscreen mode

Golden Rules Every Team Member Must Follow

1 Never commit directly to main (except hotfixes with approval)
2 Always sync before starting work
3 Always write descriptive commit messages
4 Always push feature branches and open PRs
5 Never force push main (or any shared branch)
6 Rebase locally, merge on GitHub via PR (keeps history clean)

Quick Reference Cheat Sheet (Pin This)

# Stay in sync (run often)
sync                    # your alias
# or manually:
git stash && git pull --rebase origin main && git stash pop

# Ship completed work
git add .
git commit -m "type(scope): description"
git push

# Start new work safely
git pull --rebase origin main
git checkout -b feat/your-feature-name

# Emergency hotfix
git checkout main
git pull --rebase origin main
git checkout -b hotfix/critical-bug
Enter fullscreen mode Exit fullscreen mode

Final Words
I’ve been on teams that lost entire days to merge conflicts.
I’ve been on teams that deployed 20 times per day with zero drama.
The difference was always this: discipline around syncing and branching.
Adopt this workflow today.
Enforce it in code reviews.
Put it in your onboarding docs.
Your future self — and every teammate who’s ever screamed at Git — will thank you.
Now go forth and collaborate like professionals.
Saved you from at least 47 rage-quits in 2025.
You’re welcome.

Top comments (0)