- track who authored the branch (e.g. which developer)
- trace the branch with an issue in our issue tracker (JIRA in our case)
- have a rough idea of what the branch is about (e.g. bugfix, feature, etc)
In this article, we explain our Git branch naming convention and give some general guidelines we follow to name our branches.
Git Branch Naming Convention
Out Git branch naming convention uses the following elements:
- submitter name: use the submitter name to identify who authored the branch.
- identifier from issue tracker: identifier to trace the issue on our issue tracker (JIRA) so that we can easily trace a code change with our issue tracker.
- short description: three to six keywords that explains the changes
Adding the submitter name allows you to track multiple branches for the same ticket. If
David both developed a solution for ticket
1234, we can have branches
david/1234-new-feature and clearly trace the code pushed by each developer.
Adding a short description allows you to distinguish multiple branches for the same ticket in your issue tracker. Imagine that you have one task that requires two changes: change the color of a box and change the width of a page. You can then create two branches:
Git Branch Naming Good Practices
Git is a version control system that allows developers to track changes to their codebase and collaborate with other team members. One key aspect of using Git effectively is establishing a consistent naming convention for branches. In this blog post, we will explore four key considerations when it comes to naming branches in a Git repository.
- Use descriptive names: One of the main benefits of using Git is that it allows you to track the history of your codebase. As such, it is important to choose names for your branches that accurately reflect the changes that are being made. For example, instead of using a name like "new_feature," you might use a name like "add_user_authentication." This will make it easier for you and your team to understand the purpose of the branch and the changes it contains.
- Follow a naming convention: to ensure that branches are named consistently, and use a naming convention like the one mentioned above.
- Use short, concise names: it is important to be descriptive, but you need to keep your branch names short. Long, verbose names can be difficult to read and may not be as effective at conveying the purpose of the branch. Use a few key words separated by hyphens for the name.
- Avoid using special characters: avoid using special characters in branch names at all costs. Keep only alphanumeric characters. Special characters can cause issues when working with certain tools and platforms and can make it more difficult to work with branches. Stick to using alphanumeric characters and underscores to ensure that your branch names are easy to work with.
In summary, choosing descriptive, concise, and consistent names for your Git branches can help you and your team more easily track and collaborate on changes to your codebase. By following consistent naming conventions, you can ensure that your workflow remains organized and efficient.