Hone

Lessons · Git · is it the tree or the history

Wrong files, or wrong history

Two different problems with two different sets of commands. git status answers which one you have, in one line or none.

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

Reaching for reset when a file is wrong throws away more than you meant; reaching for restore when the history is wrong does nothing at all.

How to think about it

If status shows changes, deal with those first -- they are the only thing on this road with no undo. Once it is clean, the problem is in the commits.

Worked example

git status --short
Uncommitted work. Nothing about the history is safe to try yet.
git stash
Now it is a commit object, and safe.
git status --short
Silence. Whatever is wrong now, it is in the commits.
git log --oneline
And this is the part to look at.
git stash pop
The work comes back when you are ready for it.

Your turn

Put the uncommitted work somewhere safe before touching the history.

git 

The trap

Treating a clean status as good news. It is only information: it says the problem is somewhere more expensive.

Practise is it the tree or the history on HoneA question on it now, a coding challenge where there is one, and it is remembered for review. Free, no email needed.