Branch: A separate line of work in a Git repository, so you can make changes without affecting the main code until they are ready and reviewed.
Example
Your task is to add a search filter. You create a branch called feature/search-filter, make your commits there, and the main branch stays untouched until your pull request is approved.
Why Teams Use Branches
- Several people can work on different tasks at the same time.
- Unfinished or broken work doesn't affect the stable code.
- Every change can be reviewed before it is merged.
- A bad change can be dropped by simply deleting the branch.
Common Branch Names
| Branch | Purpose |
|---|---|
| main (or master) | Stable, accepted code |
| develop | Integration branch in some teams, before release |
| feature/... | One feature or task |
| bugfix/... or hotfix/... | A bug fix, or an urgent production fix |
| release/... | Preparing a specific release |
Many teams include the ticket number, such as feature/PROJ-142-search-filter. Follow your team's convention.
Useful Commands
| Command | What it does |
|---|---|
| git branch | List local branches |
| git switch -c feature/x | Create a new branch and switch to it |
| git switch main | Move back to main |
| git branch -d feature/x | Delete a merged branch |
Before creating a branch, pull the latest main so you start from up-to-date code.
Related terms
- Main Branch: the stable branch others branch from.
- Feature Branch: a branch for one task.
- Merge: combining a branch back in.
- Pull Request (PR): how a branch is reviewed before merging.
- Git: the tool that manages branches.
Previous term: Blocker | Next term: Bug
Related guides
- Build a GitHub Portfolio That Gets You Internship Interviews
- What to Do in Your First Week of an IT Internship
- DevOps Interview Questions Test
Frequently asked questions
What is a branch in Git?
A branch is a separate line of development in a repository, so you can work on changes without affecting the main code.
Why do we use branches in Git?
To work on several tasks in parallel, keep unfinished work away from stable code, and review changes before merging.
How do I create a branch in Git?
Use git switch -c branch-name, or git checkout -b branch-name in older Git versions.
Should I work directly on the main branch?
No. In team projects, create a branch for each task and merge it through a pull request.
Explore more internship terms
The IT Internship Glossary explains 199 terms you will hear before and during your internship, with simple definitions and real examples.
Browse all 199 terms