Skip to content

Commit 7fdd730

Browse files
author
Eric James Michael Ritz
committed
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 <[email protected]>
1 parent 6ac9a17 commit 7fdd730

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
* [Ignore one file on commit (e.g. Changelog).](https://github.com/git-tips/tips#ignore-one-file-on-commit-eg-changelog)
6767
* [Stash changes before rebasing](https://github.com/git-tips/tips#stash-changes-before-rebasing)
6868
* [Fetch pull request by ID to a local branch](https://github.com/git-tips/tips#fetch-pull-request-by-id-to-a-local-branch)
69+
* [Show the most recent tag on the current branch](https://github.com/git-tips/tips#show-the-most-recent-tag-on-the-current-branch)
6970

7071
<!-- Don’t remove or change the comment below – that can break automatic updates. More info at <http://npm.im/doxie.inject>. -->
7172
<!-- @doxie.inject end toc -->
@@ -467,5 +468,10 @@ __Alternatives:__
467468
git pull origin pull/<id>/head:<branch-name>
468469
```
469470

471+
## Show the most recent tag on the current branch
472+
```sh
473+
git describe --tags --abbrev=0
474+
```
475+
470476
<!-- Don’t remove or change the comment below – that can break automatic updates. More info at <http://npm.im/doxie.inject>. -->
471477
<!-- @doxie.inject end -->

tips.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,5 +264,9 @@
264264
"title": "Fetch pull request by ID to a local branch",
265265
"tip": "git fetch origin pull/<id>/head:<branch-name>",
266266
"alternatives": ["git pull origin pull/<id>/head:<branch-name>"]
267+
},
268+
{
269+
"title": "Show the most recent tag on the current branch",
270+
"tip": "git describe --tags --abbrev=0"
267271
}
268272
]

0 commit comments

Comments
 (0)