Git prev & next
When you are doing a talk with a demo in several steps, it can be practical to have a git repository with a commit for each step. During the demo, when you want to go to the next step, all you have to do is moving to the next commit. But, except if you know the sha1 of this commit, it can be tricky to do that without interrupting your talk. I have two git aliases to suggest for this task (in ~/.gitconfig
):
[alias]
prev = checkout HEAD^1
next = "!sh -c 'git log --reverse --pretty=%H master | awk \"/$(git rev-parse HEAD)/{getline;print}\" | xargs git checkout'"
With them, you can move to the next step with a simple git next
and come back to the previous step with git prev
. Just be warned, it'll only works on the master branch.
Written by Bruno Michel
Related protips
1 Response
Thanks a lot,
I saw this in a PHP demo and wondered how it's done.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Git
Authors
Related Tags
#git
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#