Skip to content

Semantic branching

Otto edited this page Jun 26, 2024 · 2 revisions

Semantic Branching Guidelines for Team Members

Purpose:

Semantic branching helps maintain a clear and organized version control system, facilitating collaboration and integration of features across the development lifecycle. The branch name should be included in the Issue description, so you can copy the name when creating a new branch

1. Branch Naming Convention:

  • Use the format type/###-brief-description for branch names, where type is one of the following:
    • feat or feature: New feature for the user.
      • Example: feature/001-user-authentication
    • fix: Bug fix for the user.
      • Example: fix/002-fix-login-api
    • docs: Changes to the documentation.
      • Example: docs/003-update-readme
    • style: Code formatting, missing semicolons, etc. (no production code change).
      • Example: style/004-format-code
    • refactor: Refactoring production code (e.g., renaming a variable).
      • Example: refactor/005-rename-variable
    • test: Adding or refactoring tests (no production code change).
      • Example: test/006-add-unit-tests
    • chore: Updating grunt tasks, etc. (no production code change).
      • Example: chore/007-update-dependencies

2. Creating a New Branch:

  • From the GitHub issue view, click on "Create a branch for this issue" to create a branch directly tied to the issue. Use develop as the source branch.

  • Ensure that the branch name matches the specified format for the task.

    Example:

    Branch name: feature/001-user-authentication
    

    Command line instructions:

    # Assuming you're currently on the `develop` branch
    git checkout develop
    git pull origin develop
    git checkout -b feature/001-user-authentication

3. Pushing Branches:

  • Push your branch regularly to the remote repository to enable collaboration and integration.

    git push origin feature/001-user-authentication

4. Pull Requests:

  • When your task is complete, open a pull request (PR) from your branch into the develop branch.
  • Provide a concise description of the changes and reference the issue number.

5. Review and Merge:

  • Collaborate with team members for code review.
  • Address feedback and make necessary changes.
  • After approval, merge your branch into develop using the repository's merge mechanism (e.g., GitHub PR merge button)

Additional Tips:

  • Branch Management: Delete feature branches after they are merged to keep the repository clean.

    git branch -d feature/001-user-authentication  # Delete local branch
    git push origin --delete feature/001-user-authentication  # Delete remote branch
  • Naming Consistency: Ensure the branch name matches the specified format provided in each task to maintain clarity and consistency.

Example Workflow:

  1. Create a new branch directly from the GitHub issue tied to your task using develop branch as the source. You can copy the branch name from the issue if it is included. example: (type/###-brief-description).
  2. Push the branch to the remote repository.
  3. Open a pull request for review and approval.
  4. Merge the branch into develop after approval and testing.

Summary:

Using GitHub's issue view to create branches streamlines the process of tying specific tasks to branches, enhancing traceability and organization within your version control system. Adhering to these guidelines ensures a structured approach to feature development, bug fixes, documentation updates, and other tasks across your team, with branch names following the specified format.