是否有一个Git命令来获取当前标签,分支和提交? [英] Is there a single Git command to get the current tag, branch and commit?
问题描述
我目前使用三个命令的集合来获取当前标签,分支以及最近提交的日期和SHA1。
I'm currently using a collection of three commands to get the current tag, branch and the date and SHA1 of the most recent commit.
git describe --always --tag
git log -1 --format="%H%n%aD"
git rev-parse --abbrev-ref HEAD
这将输出如下:
1.2.3-5-gdeadbeef
deadbeef3b8d90071c24f51ac8f26ce97a72727b
Wed, 19 May 2010 09:12:34 +0200
master
说实话,我完全正确。但我使用这些命令从Maven和任何人使用Maven之前,知道有多少东西,如外部命令膨胀POM。我只是想减少我的pom.xml和可能减少执行时间一点。
To be honest, I'm totally fine with this. But I'm using these commands from Maven and anyone who'd used Maven before, knows how much things like external commands bloat the POM. I just want to slim down my pom.xml and maybe reduce execution time a bit.
推荐答案
我为此目的创建了一个Maven插件,这真的符合我的需求(事实上,它现在超过了它)。
I created a Maven plugin for exactly this purpose, which really fits my needs (in fact it exceeds them by now).
它被称为 Mavanagaiata ,它是开源的,可从Maven Central 。
It's called Mavanagaiata, it's open-source and available from Maven Central.
这篇关于是否有一个Git命令来获取当前标签,分支和提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!