Lessons · Git · three commands that tell you where you are
Three questions, three commands
What is uncommitted, what does the history look like from here, and which branch am I on. Everything else follows from those three answers.
Hone is a place to practise programming. This is one of its lessons, written out in full and free to read without an account.
What it is for
The commands to fix a file problem and a history problem are different, and running the wrong family is how a small mistake becomes a large one.
How to think about it
Run all three before deciding anything. They cost nothing and they narrow the problem to one half of the tool.
Worked example
git status --shortM in the FIRST column means staged. A space there and M in the second means unstaged.
git status -sbThe same, plus the branch line and how it compares with its upstream.
git log --oneline -3The last three commits from where you stand.
git branch --show-currentfeature. Worth checking before every commit, not just when something is wrong.
Your turn
Show what is changed, with the branch line at the top.
git -sb
Try it in a real repository
The trap
Reading the two status columns as one. The left is the staging area and the right is your files, and half of stage two is telling them apart.