Git prev & next

Git prev & next

GIT

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.

原文:https://coderwall.com/p/ok-iyg/git-prev-next

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。