A Day of Git
Ten chapters collapse into one loop that you run several times a day. Seen in order, in one place, it is much smaller than the book that taught it.
Starting
git switch main git pull
Begin from what the project actually is now, not from where you left it yesterday. Someone else may have merged something; you may have merged something yourself through the website. Skipping this is behind most of the confusion people report in their third week.
Working
git switch -c mobile-sightings-layout # edit, then when one idea is finished: git status git add style.css git diff --staged git commit -m "Wrap the sightings list on narrow screens"
Branch first, even for a ten-minute change. Then the loop: check where things are, stage what belongs together, read what you are about to record, commit it with a sentence.
Commit whenever a coherent piece works. Several times an hour is normal; two hours with nothing committed usually means you have three things half-done.
Interruption
git stash push -m "half-finished layout" git switch main git pull git switch -c fix-broken-link # fix, commit, push, open the pull request git switch mobile-sightings-layout git stash pop
Set the work aside, deal with the urgent thing on its own branch, come back. The drawer from Chapter 5 exists for exactly this shape of afternoon.
Finishing
git push -u origin mobile-sightings-layout # open the pull request, respond to review, merge on GitHub git switch main git pull git branch -d mobile-sightings-layout
Back where you started, with the work landed and the label cleaned up. The next piece of work begins with the same two commands as this morning.
The whole day in six commands
Look at what that transcript actually used: switch, pull, add, commit, push, status. Six commands carried an entire working day.
None of that is simplified for beginners. It is close to what a professional's day looks like, because the rare commands stay rare — you reach for revert or reflog occasionally and look up anything beyond that. Knowing this is worth something on its own: the size of Git is not the size of the job.
What the day never included
No reset. No rebase. No --force. No history rewriting of any kind.
The example was not arranged to avoid them. A normal working day on a normal project does not need any of them, which is why a book that leaves them out can still leave you able to do the job.
- "Professionals use dozens of Git commands every day." They use about six and look the rest up. The rare commands stay rare, which is why the deep dive functions as a reference rather than as memory.
- "Pulling first is optional if nobody else is working on the project." Your own merges through the website count as someone else, and so does your other laptop. Pull anyway; it costs a second.
- "I should commit once at the end of the day." A day is not one idea, and an uncommitted day is a day with no safety net at all.
- "Branching for a ten-minute change is overkill." It costs one command and keeps
mainworking. The ten-minute change is also the one most likely to get tangled with the urgent thing that arrives at 11:40.
- Seeing the whole loop at once is what turns a book of separate commands into a single habit you can run without thinking.
- The start-of-day pull is the one habit that prevents the largest share of sync problems people hit in their first month.
- Knowing that six commands carry the job removes the low-level anxiety that there is some large body of Git you have not learned yet.
Knowledge Check
Why does the day start with git switch main and git pull?
- So your work starts from what the project is now, not from yesterday
- Because Git requires a pull before any new branch can be created locally
- Because uncommitted work from yesterday is discarded unless you pull first
- Because
mainis locked overnight and the pull releases it for editing
Which six commands carried the whole working day in this topic?
switch,pull,add,commit,push,statusinit,clone,merge,rebase,reset,pushstatus,diff,log,show,blame,reflogstash,restore,revert,amend,branch,merge
Something urgent arrives while you are mid-change. What does the day's routine do?
- Stash the work, fix the urgent thing on its own branch, then pop it back
- Commit the half-finished work so nothing is lost, then switch branches
- Finish the current change first, since switching mid-change is not possible
- Discard the current change and redo it after the urgent fix has been made
What did the whole day never use?
reset,rebase,--force, or history rewriting of any kind- Branches, since a single developer can work directly on
main - The staging area, since
git commit -acovers everything at once - Pull requests, since they are only needed on large teams with reviewers
You got correct