Linux, terminal and Git

Stage 5 · Lesson 5 of 8

Branches for every change

Git fundamentals

let you work on one change without disturbing the rest. Make a new branch for each piece of work. git switch -c fix-empty-cart creates a branch and moves you onto it.

git switch main takes you back, and git branch lists all branches. A branch is only a pointer, so branches cost almost nothing. Use many short-lived ones rather than one long one.

Keep main working and try experiments elsewhere. Before switching, commit your changes or put them aside with . Otherwise Git either carries them along or refuses to switch. Name branches after the work, not after yourself.

Common trapdoing everything on main, then finding it impossible to open a clean for one change.

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

  • BookFree
    Pro Git

    Scott Chacon and Ben Straub

    The free official Git book; chapters 2 and 3 cover everything in this stage properly

  • CourseFree
    The Missing Semester of Your CS Education

    MIT · Beginner

    The version control lecture teaches Git from its data model upwards, which makes commands make sense

Practise

Keep handy

Also worth your time

Mark this stage as not done?