Branch strategy
- Git course
- Intermediate
- Lesson 75/82
- 5 min
Create a feature branch with a naming convention.
Feature branch strategy
In the feature branch strategy, a separate branch is created for each new feature or task. This allows development to proceed independently of the main branch and be reviewed when completed. Using the feature/ prefix in branch names provides consistent naming across the team.
feature/user-login
feature/payment-page
feature/search-filterBranch naming conventions
Branch names should be short, descriptive, and consistent. Using lowercase letters and separating words with hyphens improves readability. For example, feature/user-login can be used for user login development.
git switch -c feature/user-login
git branchPractice Create and list a feature branch
Create a new branch named feature/dashboard and switch to it. Then list the existing branches. Write the two commands in the correct order.
Starter code
# Yeni özellik dalını oluştur
# Dalları listeleSample solution
git switch -c feature/dashboard
git branchExpected output
Switched to a new branch 'feature/dashboard' * feature/dashboard main
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which branch name follows this strategy for developing a new user profile feature?
- main
- feature/user-profile Correct answer
- origin
- HEAD
Explanation: The feature/ prefix indicates that the branch was created to develop a new feature.
2 Create a feature branch
git switch -c ____
git switch -c feature/search-filter
Explanation: git switch -c creates a new branch and switches to it.
3 Branch naming components
| Term | Meaning |
|---|---|
feature/ |
New feature prefix |
user-login |
Short feature name |
Tire (-) |
Separates words |
Küçük harf |
Provides consistent casing |