Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 如何获取以前的标记名?_Git - Fatal编程技术网

Git 如何获取以前的标记名?

Git 如何获取以前的标记名?,git,Git,有一些标签: first second third fourth 我需要在“second”(第三个)之前获取标记。git descripe--abbrev=0秒^或在最后两个标记之间 git log $(git describe --abbrev=0 --tags $(git describe --abbrev=0)^)...$(git describe --abbrev=0) 具有任何排序的替代解决方案您希望在当前标签之后获得下一个标签: git标记--sort=-creatordate

有一些标签:

first
second
third
fourth

我需要在“second”(第三个)之前获取标记。

git descripe--abbrev=0秒^
或在最后两个标记之间

git log $(git describe --abbrev=0 --tags $(git describe --abbrev=0)^)...$(git describe --abbrev=0) 

具有任何排序的替代解决方案您希望在当前标签之后获得下一个标签:

git标记--sort=-creatordate | grep-A 1秒| tail-n1
  • git-tag--sort=-creatordate
    按创建者日期打印从最新到最旧的所有标记:“第一个第二个第三个第四个”。明智地选择排序选项
  • grep-1秒
    只过滤“second”和其后的一行,即“third”
  • tail-n1
    打印“second-third”的最后一行,我们最终得到了“third”

  • 谢谢这就是我所需要的,git descripe--abbrev=0--tags second ^在git版本2.5.0上:致命:不是有效的对象名second^你刚才复制了命令还是实际上有一个标记“second”?如果我没有得到正确的标记,原因可能是什么。在我的例子中,我可以在
    标记列表的输出中看到标记,但是上面的命令以某种方式使我位于前一个标记之前。如果git tag返回“0.44.0 0.45.0 0.47.0”,我运行命令
    git descripe--abbrev=0--tags 0.47.0^
    我得到
    0.44.0
    而不是
    0.45.0
    使用
    git log--oneline--graph--decoration
    检查修订树。您可能有一个合并提交,
    0.45.0
    来自一个分支,而
    0.47.0^
    选择另一个分支。在这种情况下,您可以尝试
    ^0.47.0