Skip to content

Instantly share code, notes, and snippets.

@imvaskii
Created December 7, 2019 04:37
Show Gist options
  • Select an option

  • Save imvaskii/d2a867365b7ddcd7e9f232135284e30b to your computer and use it in GitHub Desktop.

Select an option

Save imvaskii/d2a867365b7ddcd7e9f232135284e30b to your computer and use it in GitHub Desktop.
Bash fn for current and prev commit hash.
#!/bin/env bash
# Current commit HASH
# %H give commit hash
current_commit() {
git HEAD --pretty=format:"%H"
# git log -n 1 --pretty=format:"%H"
}
# Previous commit HASH
# %P give parent commit hash
previous_commit() {
git HEAD --pretty=format:"%P"
# git log -n 1 --pretty=format:"%P"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment