What is a Git Branch?
A Git branch is an independent line of development within a repository. It allows developers to work on new features, bug fixes, or experiments without affecting the main codebase.
Instead of everyone modifying the same files simultaneously, each developer works in their own branch. Once the work is complete and tested, it can be merged back into the main branch.
Why Branches Matter
- Enable multiple developers to work simultaneously.
- Prevent unstable code from reaching production.
- Make feature development isolated and manageable.
- Simplify collaboration.
- Allow easy rollback if something goes wrong.
Common Branch Types
Main Branch (main)
- Production-ready code.
- Stable and deployable.
- Protected in most organizations.
Development Branch (develop)
- Integration branch.
- Developers merge completed features here before production.
Feature Branch
Created for developing a single feature.
Example: