From 7fdd7304d0ec34705117bf86bdaacda82b83cd5f Mon Sep 17 00:00:00 2001 From: Eric James Michael Ritz Date: Mon, 2 Nov 2015 22:00:16 -0500 Subject: [PATCH] Add a tip to show the most recent tag This tip shows how to display the most recent tag reachable on the current branch. The use of `--abbrev=0` is necessary otherwise the output would contain additional information (specifically part of a commit hash), appended to the tag name. It's worth noting that this command is usable for branches other than the current one, e.g. $ git describe --tags --abbrev=0 master That would show the most recent tag on the `master` branch regardless of whatever branch the user is currently on. Signed-off-by: Eric James Michael Ritz --- README.md | 6 ++++++ tips.json | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index 39cf0b3..0bce4e9 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ * [Ignore one file on commit (e.g. Changelog).](https://github.com/git-tips/tips#ignore-one-file-on-commit-eg-changelog) * [Stash changes before rebasing](https://github.com/git-tips/tips#stash-changes-before-rebasing) * [Fetch pull request by ID to a local branch](https://github.com/git-tips/tips#fetch-pull-request-by-id-to-a-local-branch) +* [Show the most recent tag on the current branch](https://github.com/git-tips/tips#show-the-most-recent-tag-on-the-current-branch) @@ -467,5 +468,10 @@ __Alternatives:__ git pull origin pull//head: ``` +## Show the most recent tag on the current branch +```sh +git describe --tags --abbrev=0 +``` + diff --git a/tips.json b/tips.json index 3f445ba..72c2075 100644 --- a/tips.json +++ b/tips.json @@ -264,5 +264,9 @@ "title": "Fetch pull request by ID to a local branch", "tip": "git fetch origin pull//head:", "alternatives": ["git pull origin pull//head:"] + }, + { + "title": "Show the most recent tag on the current branch", + "tip": "git describe --tags --abbrev=0" } ]