What is a feature branch?
A feature branch is a separate branch in a version control system (such as Git), created for developing a specific new feature or improvement. It isolates work on a single task so the changes do not interfere with the rest of the code.
How it works
- The branch is created from the main one (
developormain). - The developer implements the new functionality in it.
- After it is finished and tested, the branch is merged back (via a pull request).
- After the merge it is usually deleted, to keep the repository clean.
Example
javascript
git checkout develop
git checkout -b feature/login-apiThe
feature/login-apibranch contains only the changes related to authorization.
Advantages
- Isolation - changes do not affect the stable version of the product.
- Safe testing - you can experiment without breaking the trunk.
- Easy review - each branch corresponds to one feature and is easy to check.
- Transparency - the branch name immediately shows what is being worked on.
Downsides
- Long-lived feature branches can lead to merge conflicts.
- If a branch exists for weeks, the team loses sync with the main branch.
Conclusion
A feature branch is a temporary "sandbox" for a single task. It makes development safe, manageable, and transparent, as long as the branches are short-lived and synced often with the main branch.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.