Skip to content

Instantly share code, notes, and snippets.

@thegeorgenikhil
Last active November 8, 2023 17:08
Show Gist options
  • Save thegeorgenikhil/7f82418d29cf654358019d8b167b4651 to your computer and use it in GitHub Desktop.
Save thegeorgenikhil/7f82418d29cf654358019d8b167b4651 to your computer and use it in GitHub Desktop.
Move between commits - Helpful while exploring new codebases!
# Move backward one commit back
alias gitbwd='git log --all --decorate --oneline | grep -A 1 $(git rev-parse --short HEAD) | awk "{print \$1}" | tail -1 | xargs -I {} git checkout {}'
# Move forward one commit up
alias gitfwd='git log --all --decorate --oneline | grep -B 1 $(git rev-parse --short HEAD) | awk "{print \$1}" | head -1 | xargs -I {} git checkout {}'
# See the files names that got changed between the commit
alias cdiff='git diff --name-only HEAD~1 HEAD'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment