Last active
November 27, 2022 11:08
-
-
Save miyataka/447f3f1d6be72c68bf3b32f3c95bd46a to your computer and use it in GitHub Desktop.
git history next / prev command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cf. https://coderwall.com/p/ok-iyg/git-prev-next | |
# cf. https://www.yhoka.com/posts/git-next-prev/ | |
[alias] | |
prev = checkout HEAD^1 | |
next = "!sh -c 'if [ \"$1\" = \"\" ]; then if [ \"$TARGET_BRANCH\" = \"\" ]; then if [ \"$(git branch | grep master)\" = \"\" ]; then TARGET_BRANCH=main; else TARGET_BRANCH=master; fi; fi; else TARGET_BRANCH=$1; fi; git log --reverse --pretty=%H $TARGET_BRANCH | grep $(git rev-parse HEAD) -A 1 | tail -1 | xargs git checkout' -" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment