MicrolearnENPTES

HEAD and moving through history

Lesson 10 of 24 · Git.Micro

HEAD marks where you are. Usually it points at a branch, but you can also point it at any old commit to look at the project as it was.

git switch branch moves HEAD to another branch and updates your files to match.

git checkout <hash> visits an old commit in detached HEAD state: no branch moves if you commit there.

git switch -c name <hash> creates a branch at any commit: the safe way to start work from the past.

Check yourself

In detached HEAD, what does HEAD point at?

Version 1.0 (the commit Release 1.0) needs an urgent fix. Create a branch hotfix starting at that commit and switch to it.

Do it in the browser: a real Git tool, a short mission and instant feedback. No install.

Start this lesson — free
← Branches are pointersMerging: fast-forward →

All lessons · Git.Micro