Skip to main content

Git Working Rules

๐Ÿ‘ฅ Rolesโ€‹

  • Repository Owner

    • Manage repo access
    • Prevent direct commits to develop, test, uat, prod
    • Review merge important branches: test, uat, prod
  • Maintainers (Lead Devs)

    • Manage release & hotfix branches
    • Review & merge pull requests (PRs)
    • Help define working process
  • Developers

    • Create feature/*, bugfix/*, or hotfix/* branches from develop
    • Submit PRs to develop when done.
    • Include detailed description in PRs.
    • Review and improve PRs.
  • DevOps

    • Manage deployments and system config
    • Deploy code from develop, test, uat, prod

๐Ÿ” Git Flowโ€‹

Dev is the default branch. All development starts from here.

  1. develop โ€“ Active development (default branch)

    • All new work branches are created from here
    • Only develop can merge into test
  2. test โ€“ Internal QA/testing

    • Only receives merges from develop
    • Can merge into uat
  3. uat โ€“ Pre-release, client/user testing

    • Only receives merges from test
    • Can merge into prod
  4. prod โ€“ Final, stable version

    • Only receives merges from uat

๐Ÿชด Branching Rulesโ€‹

  • You must use one of the following prefixes for branches:

    • feature/* โ€“ For new features or enhancements
    • bugfix/* โ€“ For fixing bugs found during development
    • hotfix/* โ€“ For urgent, production-critical fixes
  • All branches must be created from develop

  • Example: feature/user-login, bugfix/payment-crash, hotfix/api-down


โœ๏ธ Committingโ€‹

  • Write clear, meaningful commit messages
  • Avoid unrelated changes in a single commit

๐Ÿ”€ Mergingโ€‹

  • All changes go through Merge Requests (MRs)

  • MRs must be code reviewed

  • Use rebase on feature branches to keep history clean

  • Use merge into develop and above to retain full collaboration history

  • Merge paths must follow environment flow:

    • develop โ†’ test โ†’ uat โ†’ prod
  • Auto-merge only if tests pass (future feature)

  • Delete merged branches (except protected ones)


๐Ÿท๏ธ Versioning & Clean Codeโ€‹

  • Use tags for releases
  • Use .gitignore for non-tracked files (e.g. .env)
  • Never commit sensitive info (keys, tokens)
  • Document environment variables in README
  • No absolute paths in code (e.g. /home/user/...)

๐Ÿ’ก Best Practicesโ€‹

  • CI/CD: Auto-test & build on commit
  • Conflict resolution: Resolve before merge
  • Repo size: Keep small (limit: 5โ€“20MB)
  • Code conventions: Follow team style guides
  • Code reviews: Review before merging
  • Documentation: Keep everything documented
  • Backup: Regularly back up repo
  • Hooks: Use Git hooks to validate code before commit
  • Cleanup: Remove unused branches regularly

๐Ÿ“˜ Referencesโ€‹