From 63c10410c6d8c7c3022329911b417ee43ba69b21 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Fri, 15 Sep 2017 16:41:54 -0500 Subject: [PATCH] Add Get The Short Version Of The Latest Commit as a git til --- README.md | 3 ++- git/get-the-short-version-of-the-latest-commit.md | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 git/get-the-short-version-of-the-latest-commit.md diff --git a/README.md b/README.md index 86a56e7..e115644 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/). For a steady stream of TILs from a variety of rocketeers, checkout [til.hashrocket.com](https://til.hashrocket.com/). -_560 TILs and counting..._ +_561 TILs and counting..._ --- @@ -155,6 +155,7 @@ _560 TILs and counting..._ - [Dry Runs in Git](git/dry-runs-in-git.md) - [Excluding Files Locally](git/excluding-files-locally.md) - [Find The Initial Commit](git/find-the-initial-commit.md) +- [Get The Short Version Of The Latest Commit](git/get-the-short-version-of-the-latest-commit.md) - [Grab A Single File From A Stash](git/grab-a-single-file-from-a-stash.md) - [Grep For A Pattern On Another Branch](git/grep-for-a-pattern-on-another-branch.md) - [Grep Over Commit Messages](git/grep-over-commit-messages.md) diff --git a/git/get-the-short-version-of-the-latest-commit.md b/git/get-the-short-version-of-the-latest-commit.md new file mode 100644 index 0000000..d85f4e4 --- /dev/null +++ b/git/get-the-short-version-of-the-latest-commit.md @@ -0,0 +1,14 @@ +# Get The Short Version Of The Latest Commit + +As part of some automated scripting for an app deployment I wanted to be +able to get the short version of the latest commit to the current git repo. +Git's `rev-parse` command is the perfect fit for this. + +```bash +$ git rev-parse --short HEAD +708248b +``` + +See `man git-rev-parse` for more details. + +[source](https://stackoverflow.com/questions/5694389/get-the-short-git-version-hash)