How to Manage Git branches effectively?

How to Manage Git branches effectively?

Main Branches:

master (or main): The production-ready branch. This branch should always reflect the most stable version of the project. It should contain only tested and approved code.

develop: The integration branch where the latest completed features are merged. This branch is a step away from production and should be stable but may not be fully tested like master

Supporting Branches:

Feature (feature/): Used for developing new features or functionalities. Each feature should have its own branch, named descriptively, e.g., feature/user-auth.

Release (release/): Created from develop when the project is ready for a new release. This branch is used to prepare for the release, including final bug fixes, documentation, and other last-minute tasks.

Hotfix (hotfix/): Created from master to address critical issues found in the production environment. These changes are then merged back into both master and develop to ensure consistency.

Workflow:

Feature Development:

  1. Start from the develop branch and create a new feature branch.
  2. Develop the feature in the feature branch.
  3. Merge the feature branch back into develop once the feature is complete and tested.
  4. Delete the feature branch after merging to keep the repository clean

Releases:

  1. When preparing a new release, create a release/ branch from develop.
  2. Perform final tests, fixes, and versioning updates in the release/ branch.
  3. Once ready, merge the release/ branch into both master and develop.
  4. Tag the commit in master with the release version number.
  5. Delete the release/ branch after merging

Hotfixes:

  1. Create a hotfix/ branch from master to fix critical issues.
  2. After the fix is applied, merge the hotfix/ branch back into both master and develop.
  3. Tag the commit in master with an updated version number (e.g., v1.0.1).
  4. Delete the hotfix/ branch after merging


要查看或添加评论,请登录

社区洞察

其他会员也浏览了