Junior — Middle
What is the difference between development approaches using the main branch and feature branches?
sobes.tech AI
Answer from AI
The approach with a main branch (e.g., main or master) and feature branches is used to organize the development process and manage code changes.
-
Main branch — contains stable, release-ready code. Only verified and tested changes are merged into it.
-
Feature branches — created for developing new features or fixing bugs. Developers work in their own branch without affecting the main.
Advantages of this approach:
- Isolation of new feature development, reducing the risk of breaking stable code.
- Convenience for team collaboration and parallel development.
- Ability to conduct code reviews and testing before merging.
After completing work, the feature branch is merged into the main via a pull request or merge, usually after passing tests.
Example:
git checkout -b feature/new-login
# work on the new feature
# commits
git push origin feature/new-login
# create a pull request to merge into main