diff --git a/coding-standards/git.md b/coding-standards/git.md index decefc1..1326f00 100644 --- a/coding-standards/git.md +++ b/coding-standards/git.md @@ -1,106 +1,298 @@ -Git Standards Document -====================== +# Git Standards Document -Introduction: ------------------ +## Introduction This document outlines the standards and conventions for using Git within our company. Adhering to these standards ensures consistency, clarity, and efficiency in managing and collaborating on projects. -Git Configuration: ----------------------- +## Table of Contents -- Username and Email: Ensure your Git configuration is set with your real name and work email. +- [Git Standards Document](#git-standards-document) + - [Introduction](#introduction) + - [Table of Contents](#table-of-contents) + - [1. Git Configuration](#1-git-configuration) + - [2. Repository Structure](#2-repository-structure) + - [Main/Master Branch](#mainmaster-branch) + - [Development Branch](#development-branch) + - [Branch Protection Rules](#branch-protection-rules) + - [Feature Branches](#feature-branches) + - [3. Commit Messages](#3-commit-messages) + - [Commit Message Format](#commit-message-format) + - [Type](#type) + - [Subject](#subject) + - [Body](#body) + - [Footer](#footer) + - [Commit Message Samples](#commit-message-samples) + - [Revert](#revert) + - [4. Commit Granularity](#4-commit-granularity) + - [5. Pull Requests (PRs)](#5-pull-requests-prs) + - [6. Submitting a Pull Request (PR)](#6-submitting-a-pull-request-pr) + - [After your pull request is merged](#after-your-pull-request-is-merged) + - [7. Code Reviews](#7-code-reviews) + - [8. Conflict Resolution](#8-conflict-resolution) + - [9. Tagging and Releases](#9-tagging-and-releases) + - [Conclusion](#conclusion) + +## 1. Git Configuration + +- Username and Email: Ensure your Git configuration is set with your real name and work email. ```bash - git config --global user.name "Your Name" + git config --global user.name "Your Name" git config --global user.email "your.email@company.com" ``` -Repository Structure: -------------------------- - -- Master/Main Branch: - - Try to have `main` branch instead of `master`. - - The `main` branch should always be deployable. - - All commits on `main` should be made through pull requests. -- Development Branch: - - Use a `development` or `dev` branch for integration and testing. -- Set branch protection rules for `main` and `development` branches to restrict developers to push unverified changes and allow only maintainers to push/merge. Here is the quick read on how to set branch protection rules - https://docs.gitlab.com/ee/user/project/protected_branches.html -- Feature Branches: - - Create separate branches for individual features or bug fixes. - - Name them descriptively, e.g., `feature/user-authentication`, `bugfix/password-reset`. - -Commit Messages: --------------------- - -- Write clear, concise, and descriptive commit messages. -- Use the imperative mood ("add" instead of "added"). -- Start with a capital letter. -- Do not end the commit message with a period. - - Example: `Add user authentication` -- Always put your commit message in the below context & frame a proper message like this, - - If applied this commit will, \ - - Example 1: `Add validation to the email field` - - Example 2: `Update get users API response with lastname` - -Commit Granularity: ------------------------ - -- Make small, atomic commits that logically separate changes. -- Avoid mixing unrelated changes in a single commit. - -Pull Requests (PRs): ------------------------- - -- Create PRs for merging changes into the `main` or `development` branches. -- Ensure PRs are reviewed and approved by peers before merging. -- Provide a detailed description in the PR. Use the body to explain what is it, why is it needed and how is it done, - - ``` - - - - ``` -- It is always a best practise to maintain checklist in every PR to make sure everything is submitted properly along with your PR. Example checklist can be, - - ``` - [ ] No build errors - [ ] No linting issues - [ ] No formatting issues - [ ] Changes Tested Locally - [ ] Added PR title as per standards - [ ] Added PR description as per standards - [ ] Attached document link - [ ] Attached test cases file - [ ] Updated deployment checklist - ``` -- To maintain a clean and organized commit history, use the "squash and merge" option when creating a Pull Request (PR) against the development branch. - -Code Reviews: ------------------ - -- Conduct code reviews for every PR to ensure code quality and consistency. -- Address all feedback and comments before merging the PR. -- If you have CI setup, then ensure that CI passes before merging the PR. - -Conflict Resolution: ------------------------- - -- Resolve merge conflicts promptly. -- Ensure conflicts are resolved locally before pushing changes. -- Ensure that you test your changes locally after resolving conflicts. - -Tagging and Releases: --------------------------- - -- Use semantic versioning for your projects. -- Create a tag for each release. -- Always add release description. +## 2. Repository Structure -```bash +### Main/Master Branch + - Try to have `main` branch instead of `master`. + - The `main` branch should always be deployable. + - All commits on `main` should be made through pull requests. + +### Development Branch + - Use a `development` or `dev` branch for integration and testing. + - The `development` branch should always contain the latest implemented changes intended for the next release. + +### Branch Protection Rules + - Set branch protection rules for `main` and `development` branches to restrict developers to push unverified changes and allow only maintainers to push/merge. + - Here is the quick read on how to set branch protection rules: + - github: https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/managing-a-branch-protection-rule + - gitlab: https://docs.gitlab.com/ee/user/project/protected_branches.html + +### Feature Branches + - Create separate branches for individual features or bug fixes. + - Do NOT combine multiple features in a single branch. Always create SEPARATE branches for different changes. + - Feature branch should have short but descriptive names. + - Accepted naming formats are using task [type](#type) as prefix, forward slash `/`, followed by a short `kebab-case-description`. + - Examples: `feature/user-authentication`, `bugfix/password-reset`, `chore/update-api-version` etc. + - Note: Some projects may use `task shortcode` as branch name instead. Consult the Project Manager for what format to follow. + +## 3. Commit Messages + +- Write clear, concise, and descriptive commit messages. +- Use the imperative mood ("add" instead of "added"). +- Start with a capital letter. +- Do not end the commit message with a period. + - Example: `Add user authentication` +- Always put your commit message in the below context & frame a proper message like this, + - If applied this commit will, \ + - Example 1: `Add validation to the email field` + - Example 2: `Update get users API response with lastname` + +### Commit Message Format + +Each commit message consists of a **header**, a **body** and a **footer**. The header has a special format that includes a **type**, a **scope** and a **subject**: + +```shell + : + + + +