Russian version

Use the power of Git to show demo in your presentations

Use the power of Git to show demo in your presentations

A coding demo quite often accompanies technical presentations. While the code is the most exciting part, the typing is usually boring, no matter how fast the presenter types. At the same time, it usually makes sense to show the code step-by-step when it continually evolves.

To achieve this you can utilize git and switch between commits during the presentation. It is not so convenient to switch commits by commit sha, though. So we can do the trick — introduce git prev and git next aliases to navigate between commits. To introduce git alias update .gitconfig file in your user’s folder:

[alias]
    prev = checkout HEAD^1
    next = "!sh -c 'git log --reverse --pretty=%H master | awk \"/$(git rev-parse HEAD)/{getline;print}\" | xargs git checkout'"
    p = checkout HEAD^1
    n = "!sh -c 'git log --reverse --pretty=%H master | awk \"/$(git rev-parse HEAD)/{getline;print}\" | xargs git checkout'"

As you can see from the configuration above, I also added git p and git n aliases to save time during the presentation. Now you can start the presentation for the first commit and then run git next / git n once you need to move forward. Also, if you want to step back, use git prev / git p.

git history

Tag your commits with git tag so that could be a hint for you about the commit. Here is a quick video how it could look like:

As a bonus for this approach, after the presentation, you can provide demo codes with step-by-step history so everyone will be able to follow the demo.

Known limitations

  1. You can only use master branch to use these aliases.
  2. Your history should be linear, so no branches in the demo repo.
  3. You have to use git terminal during the presentation. You can use an integrated IDE terminal for this purpose, though.
← → How to find buggy commit using git bisect

Add a comment

Gravatar is used to display the avatar
You can format text using Markdown