History

History

In a nutshell, history allows you to see a git repository like a collection of commits and references

history with pointers
History

Which commit is a new one linked to?

The answer is "the commit pointed to by HEAD"

History

The special tag HEAD

HEAD is a special reference, pointing to the last commit of the current working branch
in an ordinary situation

HEAD tag
History

Which operations move HEAD?

History

What if we want to move HEAD
to a specific commit?

To do this we can use the checkout command with the hash of the commit we want move HEAD to

git checkout <commit_hash>
detached HEAD n.b. when HEAD points to a specific commit not pointed to by a branch, we call it detached HEAD