What is a branch in Git?
A branch is a separate line of work in a Git repository where you can try changes safely. Your main version stays the same until you choose to bring those changes in.
An example
You want to test a new homepage design. You make a branch called new-homepage, try it there, and bring it into main only once you like it.
Where you’ll meet it
- Make a change on a branch · Save your code on GitHub
- Open a pull request · Save your code on GitHub
- Make a change on a branch · Save your code on GitLab
- Open a merge request · Save your code on GitLab
- Should I set up Git and GitHub now or later? · Saving your code
- How do commits, branches, main and origin work? · Saving your code