Navigation, status and history: status, log, checkout, diff, show

Navigation and history #

Status #

Before performing any operation with git, it is common practice to execute

git status

Among other things, this command will display:

  • the current position of the HEAD pointer,
  • which files have been modified since the last commit,
  • pending conflicts (if any),
  • etc.

You can also display the detail of all modification made since the last commit (on the current branch) with

git diff

History #

git log

displays the history of the current branch, i.e. all its commits (with their ID, date, author and commit message).

To display the modifications made by a specific commit, run

git show <ID>

where <ID> consists of the first digits of the commit ID.

The git checkout command moves the HEAD pointer. In particular

git checkout <myBranch>

allows you to move the HEAD to a branch pointer, whereas

git checkout <ID>

allows you to switch to an existing commit in a detached state (where <ID> consists of the first digits of the commit ID).