使用Git标签-无法提取新标签

hyp*_*ils 3 git bitbucket

我们是2个人尝试在bitbucket上使用git。开发人员正在使用简单的标签来跟踪所有提交-质量检查人员正在尝试根据标签提取新代码。

所以开发者决定

git commit -v -am "($date) $comments"
git tag -a version-1 -m "($date) $comments"
git push --tags
Run Code Online (Sandbox Code Playgroud)

质量检查人员做了

  git clone <path> ; cd $dir
  git checkout tags/version-1
Run Code Online (Sandbox Code Playgroud)

这样做是第一次-但是第二次-需要更新标签-它会给出错误消息。

第一次进行质量检查

  • 签出成功消息

    注意:签出“标签/版本1”。

    You are in 'detached HEAD' state. You can look around, make experimental
    changes and commit them, and you can discard any commits you make in this
    state without impacting any branches by performing another checkout.
    
    If you want to create a new branch to retain commits you create, you may
    do so (now or later) by using -b with the checkout command again. Example:
    
      git checkout -b <new-branch-name>
    
    HEAD is now at 0c3514c... (02-28-2016) test comments
    
    Run Code Online (Sandbox Code Playgroud)

然后开发人员进行了更改,然后执行了

 git commit -v -am "($date) $comments"
 git tag -a version-2 -m "($date) $comments"
 git push --tags
Run Code Online (Sandbox Code Playgroud)

它经历了-我们可以在repo上看到新标签-进行了更改。

质量检查人员会进行更改

 git checkout tags/version-2
Run Code Online (Sandbox Code Playgroud)

错误消息是

error: pathspec 'tags/version-2' did not match any file(s) known to git.
Run Code Online (Sandbox Code Playgroud)

如果进行质量检查

  git clone <path> ; cd $dir
  git checkout tags/version-2
Run Code Online (Sandbox Code Playgroud)

它工作正常!质量检查人员如何用开发人员正在签入的新标签更新同一git Director?

hyp*_*ils 5

好的-我在浏览堆栈上的其他链接时找到了答案。

首先,通过执行以下操作确保该标记在本地存在

git fetch --tags
Run Code Online (Sandbox Code Playgroud)

然后通过运行签出标签

git checkout tags/<tag_name>
Run Code Online (Sandbox Code Playgroud)

感谢Git-当两个遥控器具有相同的标签名称时签出一个远程标签(第二个答案)