首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >Git prev & next

Git prev & next

作者头像
iOSDevLog
发布2020-11-12 11:03:25
发布2020-11-12 11:03:25
9800
举报
文章被收录于专栏:iOSDevLogiOSDevLog

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):

代码语言:javascript
复制
[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

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除
目录
  • Git prev & next
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档