Branching Conventions #21
MFarabi619
started this conversation in
Conventions and Best Practices
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Git Branching Best Practices
Main Branch is Always Deployable: The 'main' branch should always be in a deployable state. This means it should not contain any half-done features or bug fixes. Everything that is in 'main' should be 100% complete and tested.
Create Descriptive Branch Names: It's best to create branch names that are descriptive and reflect the purpose of the work to be done on that branch. For example, if you're working on a new login feature, you might call your branch 'feature/login'.
One Feature or Bug Fix Per Branch: Each branch should be used for a single purpose - either for developing a new feature or for fixing a bug. This helps in keeping changes isolated and managing them better.
Regularly Pull from Master: Regularly pull updates from 'master' to your feature branches. This ensures that you are always working with the latest code and can avoid merge conflicts when it's time to merge your feature back into 'master'.
Merge Requests for Code Review: Before merging your branch back into 'master', use a merge request (or pull request in GitHub). This gives others on your team the opportunity to review your code and provide feedback.
Delete Branches After Merging: Once a branch has been merged back into 'master', delete the branch. This helps to keep the repository clean and manageable.
Use Tags for Releases: If you want to mark a specific point in your 'master' branch as a particular release or version, use a tag. This allows you to easily refer back to specific releases in the future.
Avoid Long-Lived Branches: The longer a branch lives separate from the 'master' branch, the higher the chances of encountering conflicts when it's time to merge. Regularly merging 'master' into your branch (or rebasing your branch on 'master') can help to mitigate this.
Regularly Push Your Work: Regularly pushing your work to the remote repository not only serves as a backup, it also makes it easier for others to collaborate with you on a feature or a fix.
Remember, these are just general best practices and may not be suitable for every workflow. Always use the branching strategy that best fits your team's needs.
Beta Was this translation helpful? Give feedback.
All reactions