Search code examples
gitpresentation

How to move through git commits


I have a linear commit history. I want to use git for presentations.

  1. How to get to first commit and move through the history till last in order of making commmits.
  2. How to move back and forth between lists.

Solution

  • Go to the previous commit:

    $ git checkout HEAD~1
    

    Go to the next commit:

    $ git log --reverse --pretty=%H | grep -A 1 $(git rev-parse HEAD) | tail -n1 | xargs git checkout
    

    Here, --reverse output the commits chosen to be shown in reverse order.
    e.g. git log -10 --reverse would get last 10 commits then reverse it.