MicrolearnENPTES

Branches are pointers

Lesson 9 of 24 · Git.Micro

A branch lets you work on something new without touching the main line. In Git it is just a label that points at a commit, so creating one is instant.

git branch lists branches; git switch -c name creates one and moves to it (git checkout -b in older guides).

New commits move the branch you are on forward; every other branch stays where it was.

main is just the conventional name of the main branch: technically it's like any other.

Check yourself

You're on dark-mode and make a commit. What happens to main?

Nothing: it keeps pointing at the same commit

Create a branch dark-mode, switch to it and commit a new file dark.css there. main must stay where it is.

echo "body { background: #111 }" > dark.css

Do it in the browser: a real Git tool, a short mission and instant feedback. No install.

Start this lesson — free
← Ignore files with .gitignoreHEAD and moving through history →

All lessons · Git.Micro