Branching
Git branching is a way to create separate versions of your project within the same repository. Each
branch is like a copy of your code where you can make changes, work on new features, or fix bugs without affecting
the main version (branch) of your project. Branches help keep your work organized and allow multiple people to work on
different tasks at the same time without interfering with each other.
Use Cases:
- Feature Development
- Bug Fixing
- Refactoring Code
- Code Review
- Release Management
- Team Collaboration
- Experimentation
Examples:
Creating a new branch:
git branch [branch-name]
Removing a branch:
git branch -d [branch-name]
Change to different branch:
git checkout [branch-name]
Create and change to new branch:
git checkout -b [branch-name]
Rename a branch:
git branch -m [branch-name]