Hone

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 --short
M in the FIRST column means staged. A space there and M in the second means unstaged.
git status -sb
The same, plus the branch line and how it compares with its upstream.
git log --oneline -3
The last three commits from where you stand.
git branch --show-current
feature. 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

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.

Practise three commands that tell you where you are on HoneA question on it now, a coding challenge where there is one, and it is remembered for review. Free, no email needed.