User Tools

Site Tools


ubuntu:git:git_describe

Ubuntu - GIT - git describe

All this command does is show you the most recent annotated tag that is reachable from a commit.

This may be useful for build and release scripts and also to find out which version a change was introduced.

This command takes a reference or commit hash and response with the most recent tag.

If there was a commit after the tag, the tag will be followed by the number of commits and a letter “g” with the new commit hash.

git init
Initialized empty Git repository in /home/john/Projects/git-stash-test/.git/
 
echo "bacon" > bacon.txt
git add bacon.txt
git commit -am "add bacon file"
[master (root-commit) 12da48f] add bacon file
 1 file changed, 1 insertion(+)
 create mode 100644 bacon.txt
 
git branch
* master
 
git tag -a v1.0 -m "This is the first version"
 
git describe
v1.0
 
git show v1.0
tag v1.0
Tagger: John Smith <john.smith@gmail.com>
Date:   Wed Jul 22 04:39:15 2015 -0700
 
This is the first version
 
commit 12da48ff9c54f0f7a5a38fe6d7bde58fc8550dfe
Author: John smith <john.smith@gmail.com>
Date:   Wed Jul 22 04:39:15 2015 -0700
 
    add bacon file
 
diff --git a/bacon.txt b/bacon.txt
new file node 100644
index 0000000..6e953b2
--- /dev/null
+++ b/bacon.txt
@@ -0,0 +1 @@
+bacon
 
echo "cheese" > cheese.txt
git add cheese.txt
git commit -am "add cheese file"
[master 6114528] add cheese file
 1 file changed, 1 insertion(+)
 create mode 100644 cheese.txt
 
git describe
v1.0-1-g6114528
 
git log --oneline 6114528
6114528 add cheese file
12da48f add bacon file
ubuntu/git/git_describe.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki