Lesson 01 of 06Concept
What is a Branch?
Goal: Understand that a branch is a movable label pointing at a commit.
A branch is a label
A branch is a name that points at one commit. That's all it is. main is not special: it is simply the branch Git creates for you in a new repository.
When you commit, the branch you are on moves forward to the new commit automatically.
main points at the newest commit. The commits before it are its history.Creating a branch is instant
Creating a branch adds a second label to the commit you are on. Git copies no files and duplicates no history, which is why branches are cheap and people create them all the time.
Two lines of work
Step 1 of 4
One branch, main, pointing at the latest commit.
Step 1 of 4. One branch, `main`, pointing at the latest commit.
Why teams use branches
- Work on a feature without breaking the version everyone else relies on.
- Try an idea, and throw the branch away if it does not work out.
- Keep several pieces of work in progress without mixing them up.
