History
History
In a nutshell, history allows you to see a git repository like a collection of commits and references
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
History
Which operations move HEAD?
- Changing branch (switch)
move HEAD to the last commit of another branch
- Creating a commit (commit)
move HEAD to the new commit
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>
n.b. when HEAD points to a specific commit not pointed to by a branch, we call it detached HEAD