Programming foundations

Stage 2 · Lesson 4 of 8

Branches and merging

Command line and Git

A is a movable label pointing at a commit. It lets you work on a feature without touching the main line of work. git switch -c add-export creates a branch and moves to it, git switch main goes back, and git branch lists them.

When the feature is done, switch to main and run git merge add-export. If main has not moved, just slides the label forward, which is called a . If both sides have new commits, it creates a that joins them.

Keep main working at all times, and make every change on a short-lived branch. That is exactly the habit rely on. Rebase is another way to combine work, and it can wait.

A question to check yourself, an AI practice session and 2 cheat sheet entries come when you add the roadmap to your account. Add it

Resources for this stage

Start with· follow one of these

Practise

  • Draws the commit graph as you type, so merge and rebase stop being a mystery

  • Levels 0 to 15 build real shell reflexes: finding files, reading them, permissions

Keep handy

  • Free official book: read chapters 1 to 3, keep the rest for later

  • Recovery recipes for the day a commit goes wrong

Also worth your time

Mark this stage as not done?