Version Control Best Practices | Git Workflows
Master Git workflows for teams. Branching strategies, commit conventions, PR practices, and merge strategies. GitScrum links commits to tasks.
9 min read
Version control is the foundation of collaborative developmentβit enables teams to work on code simultaneously, track changes, and coordinate releases. GitScrum integrates directly with GitHub and GitLab to connect commits, branches, and pull requests to tasks, creating full traceability from idea to deployment. The right branching strategy and commit practices make the difference between smooth collaboration and merge conflict chaos.
Branching Strategies
| Strategy | Complexity | Best For |
|---|---|---|
| Trunk-based | Low | Continuous deployment |
| GitHub Flow | Low | Regular releases |
| GitFlow | High | Scheduled releases |
| Forking | Medium | Open source |
Branching Workflows
BRANCHING STRATEGIES COMPARISON
TRUNK-BASED DEVELOPMENT:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β main βββββββββββββββββββββββββββββββββββββββ β
β β² β± β² β± β² β± β
β β β β β
β (small, short-lived branches) β
β β
β Characteristics: β
β βββ Small, frequent commits to main β
β βββ Feature flags for incomplete work β
β βββ Branches live < 1 day β
β βββ Continuous integration essential β
β β
β Best for: Continuous deployment teams β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
GITHUB FLOW:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β main βββββββββββββββββββββββββββββββββββββββ β
β β² β± β² β± β
β β²βββββββββ± β²βββββββββ± β
β feature-x feature-y β
β β
β Workflow: β
β 1. Branch from main β
β 2. Commit to branch β
β 3. Open PR when ready β
β 4. Review and discuss β
β 5. Merge to main β
β 6. Deploy from main β
β β
β Best for: Simple, regular release cycles β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
GITFLOW:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β main βββββββββββββββββββββββββββββββββββββββ β
β β² β± β
β develop βββββββββββββββββββββββββββββ β
β β± β² β± β
β feature-a feature-b β
β β² β
β release/1.0 β
β β² β
β hotfix ββββββββββββββββββββββββββ β
β β
β Branches: β
β βββ main: Production code β
β βββ develop: Integration branch β
β βββ feature/*: New features β
β βββ release/*: Release preparation β
β βββ hotfix/*: Production fixes β
β β
β Best for: Scheduled releases, versioned β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Branch Naming
BRANCH NAMING CONVENTIONS
STRUCTURE:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β type/description β
β type/issue-description β
β β
β Examples: β
β βββ feature/user-authentication β
β βββ feature/GS-123-export-csv β
β βββ fix/login-timeout-error β
β βββ fix/GS-456-missing-validation β
β βββ refactor/simplify-payment-flow β
β βββ docs/api-documentation β
β βββ chore/update-dependencies β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
TYPES:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β feature/ - New features β
β fix/ - Bug fixes β
β hotfix/ - Urgent production fixes β
β refactor/ - Code refactoring β
β docs/ - Documentation β
β chore/ - Maintenance tasks β
β test/ - Test additions β
β release/ - Release preparation β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
RULES:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β β Lowercase only β
β β Hyphens to separate words β
β β Include ticket number if applicable β
β β Descriptive but concise β
β β
β β feature/NewUserAuthenticationSystem β
β β feature/user-auth β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Commit Messages
COMMIT MESSAGE CONVENTIONS
CONVENTIONAL COMMITS FORMAT:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β type(scope): subject β
β β
β [optional body] β
β β
β [optional footer] β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
TYPES:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β feat: New feature β
β fix: Bug fix β
β docs: Documentation only β
β style: Formatting (no code change) β
β refactor: Code change (no feature/fix) β
β perf: Performance improvement β
β test: Adding/fixing tests β
β chore: Build, tools, dependencies β
β ci: CI configuration β
β revert: Reverting previous commit β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
GOOD COMMIT MESSAGES:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β feat(auth): add password reset functionality β
β β
β fix(api): handle null response from payment β
β β
β refactor(dashboard): simplify chart rendering β
β β
β docs(readme): update installation instructions β
β β
β feat(export): add CSV export for reports β
β β
β Implements export functionality requested in β
β GS-123. Supports date filtering and column β
β selection. β
β β
β Closes #123 β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
BAD COMMIT MESSAGES:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β β "fix" β
β β "WIP" β
β β "updates" β
β β "fixed bug" β
β β "changed stuff" β
β β "asdfjkl" β
β β "please work" β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Pull Requests
PULL REQUEST BEST PRACTICES
PR SIZE:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β Ideal PR size: β
β βββ < 400 lines of code changes β
β βββ Single focused purpose β
β βββ Reviewable in 30-60 minutes β
β β
β Large PRs cause: β
β βββ Slower reviews β
β βββ More bugs missed β
β βββ Review fatigue ("LGTM") β
β βββ Merge conflicts β
β β
β Break large work into stacked PRs β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
PR DESCRIPTION TEMPLATE:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β ## What β
β Brief description of changes β
β β
β ## Why β
β Context and motivation β
β β
β ## How β
β Implementation approach β
β β
β ## Testing β
β How was this tested? β
β β
β ## Screenshots (if UI) β
β Before/after if applicable β
β β
β ## Checklist β
β - [ ] Tests added/updated β
β - [ ] Documentation updated β
β - [ ] No console.logs β
β β
β Closes #123 β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
REVIEW WORKFLOW:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β 1. Author creates PR with description β
β 2. CI runs (tests, linting) β
β 3. Reviewers assigned automatically or β
β manually β
β 4. Reviewers comment within 24 hours β
β 5. Author addresses feedback β
β 6. Approval(s) obtained β
β 7. Author merges (squash/merge/rebase) β
β 8. Branch deleted β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Merge Strategies
MERGE STRATEGIES
MERGE COMMIT:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β main ββββββββββββββββββββββββ β
β β² β± β
β βββββββββββββ β
β feature branch β
β β
β Pros: β
β βββ Preserves all history β
β βββ Easy to see branch context β
β βββ Can revert entire feature β
β β
β Cons: β
β βββ History can be messy β
β βββ Many merge commits β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
SQUASH AND MERGE:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β main ββββββββββββββββββββββββ β
β β² β± β
β βββββββββββββ β squashed to 1 β
β β
β Pros: β
β βββ Clean, linear history β
β βββ One commit per feature β
β βββ Easy to understand main history β
β β
β Cons: β
β βββ Loses individual commit context β
β βββ Can't bisect within feature β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
REBASE AND MERGE:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β main βββββββββββββββββββββββββββββββββββ β
β (rebased commits) β
β β
β Pros: β
β βββ Linear history β
β βββ Preserves individual commits β
β βββ Clean and detailed β
β β
β Cons: β
β βββ Rewrites history β
β βββ Can cause issues if misused β
β βββ Loses merge context β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
RECOMMENDATION:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β Most teams do well with: β
β βββ Squash for feature branches β
β βββ Merge for release/long-lived branches β
β βββ Pick one approach and be consistent β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Git Workflow Tips
DAILY GIT PRACTICES
STAY CURRENT:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β # Start of day: update main β
β git checkout main β
β git pull origin main β
β β
β # Rebase branch on latest main β
β git checkout feature-branch β
β git rebase main β
β β
β # Or merge main into branch β
β git checkout feature-branch β
β git merge main β
β β
β Avoid diverging too far from main β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
COMMIT OFTEN:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β β Commit when you have a working change β
β β Commit before trying something risky β
β β Commit at end of day (WIP if needed) β
β β
β Small commits: β
β βββ Easier to review β
β βββ Easier to revert β
β βββ Better bisect debugging β
β βββ More granular history β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
CLEAN UP BEFORE PR:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β Before opening PR: β
β βββ Rebase on latest main β
β βββ Squash WIP commits if desired β
β βββ Write good commit messages β
β βββ Remove debug code β
β βββ Run tests locally β
β β
β # Interactive rebase to clean up β
β git rebase -i main β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Handling Conflicts
MERGE CONFLICT RESOLUTION
PREVENTING CONFLICTS:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β βββ Small, frequent merges β
β βββ Communicate with team β
β βββ Update branch regularly β
β βββ Keep PRs small β
β βββ Avoid long-lived branches β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
RESOLVING CONFLICTS:
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β 1. Understand both changes β
β 2. Communicate with other author if needed β
β 3. Choose correct resolution β
β 4. Test thoroughly after resolving β
β 5. Commit resolution with clear message β
β β
β # Conflict markers β
β <<<<<<< HEAD β
β your changes β
β ======= β
β their changes β
β >>>>>>> feature-branch β
β β
β Remove markers, keep correct code β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Best Practices
Anti-Patterns
β Long-lived branches
β Cryptic commit messages
β Giant PRs (1000+ lines)
β Merging without review
β Force pushing to shared branches
β Committing to main directly