Why do developers create a Git branch for a new feature?
Options
- To delete old code without touching the main branch of the repo
- To work in isolation until changes are reviewed and merged (Correct option)
- Branches make the code run faster when it is deployed
- Git requires one separate branch for each file of the project
Answer
To work on changes in isolation without affecting the main branch until they are reviewed and merged
Why
A branch is a separate line of work. You can commit freely on feature/login while main stays stable and deployable.
When the feature is ready, you open a pull request, teammates review it, and it is merged into main.
Remember
Branch = safe parallel workspace.