13. Reset moves the note; the flags say what follows
Reset moves the current branch to a commit, then optionally makes the index match (mixed, the default) and the working tree match (hard); only uncommitted work can be lost.

13. Reset moves the note; the flags say what follows

Reset moves the current branch to a commit, then optionally makes the index match (mixed, the default) and the working tree match (hard); only uncommitted work can be lost.

Reset is the command people fear most and it is three steps.

git reset moves the branch under HEAD to a commit you name. That is the first step. Always.

With soft, it stops there. The tray and your files keep what they had.

With no flag, the tray is made to match the commit too. Your files keep their changes.

With hard, your files are made to match as well. Changes that were never committed are gone.

The commits you moved away from are not deleted. The reflog has them. Uncommitted work is the only thing a hard reset can lose.

Check yourself. Which flag can lose work that was never committed?

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime

Collaborators