Chapter Two

Everyday Git

The daily loop every developer runs — create or clone a repo, stage and commit, read the current state, ignore what should never be tracked, and undo or shelve work when plans change.

6 topics

Chapter 1 installed the model; this chapter is the muscle memory built on top of it. These are the six commands you run dozens of times a day — getting a repo, recording work, checking where you stand, keeping junk out of history, and backing out of mistakes — and every one of them is just moving content between the working tree, the index, and HEAD you already know.

The payoff of doing these well is a history that is worth reading and changes that are safe to undo. Stage deliberately and your commits review cleanly; read state before you act and you stop destroying work; know reset from revert and you never break a teammate's clone. The mechanics are small, but the discipline is what separates a tidy repo from a folder of regret.

The everyday loop
Editworking tree
git addstage to index
git commitrecord snapshot
git pushupload commits
Remoteshared repo

Topics in This Chapter