git 如何将标签推送到gerrit中的特定分支
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17953713/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to push tag to specific branch in gerrit
提问by Frank
I have a branch called v2.0
in gerrit. Now I want to the current stat of this branch as v2.0.1
.
我有一个叫v2.0
gerrit的分支。现在我想将此分支的当前统计信息设为v2.0.1
.
In my local repository I checked out the branch, then added the tag using
在我的本地存储库中,我检出了分支,然后使用添加标签
git tag v2.0.1
Now I'm trying to push that to gerrit, but I'm not sure how. I tried this:
现在我正试图将其推向 gerrit,但我不确定如何。我试过这个:
$ git push origin v2.0.1 HEAD:refs/heads/v2.0
! [remote rejected] v2.0.1 -> v2.0 (prohibited by Gerrit)
How can I push the tag to gerrit?
如何将标签推送到 gerrit?
回答by Frank
After some googling, I found the answer:
经过一番谷歌搜索,我找到了答案:
gerrit
accepts only annotated tags. It's quite straightforward to create and push an annotated tag:
gerrit
只接受带注释的标签。创建和推送带注释的标签非常简单:
git checkout v2.0
git tag -am "Adding v2.0.1 tag" v2.0.1
git push origin v2.0.1 HEAD:refs/heads/v2.0
回答by lijinma
- Add the permissions:
- 添加权限:
Click your project Access
, add permissions as following:
单击您的项目Access
,添加权限如下:
Reference:
refs/tags/*
Push Annotated Tag
Push Signed Tag
- Add your tags
- 添加您的标签
Annotated tag: git tag -a "message" tag_name
注释标签: git tag -a "message" tag_name
Signed tag: git tag -s tag_name
签名标签: git tag -s tag_name
- push your tags
- 推送你的标签
simple cmd: git push --tags
简单的命令: git push --tags
If you want to fetch tags from your server repo using cmd:
如果要使用 cmd 从服务器存储库中获取标签:
git fetch --tags
git fetch --tags
You can check the doc:
您可以查看文档:
https://review.typo3.org/Documentation/access-control.html#category_push_annotatedhttps://review.typo3.org/Documentation/access-control.html#category_push_signed
https://review.typo3.org/Documentation/access-control.html#category_push_annotated https://review.typo3.org/Documentation/access-control.html#category_push_signed
回答by CharlesB
Tags and branches are completely independent concepts in Git, so your command doesn't make sense. A tag only links to a commit, and is repository-wide.
标签和分支在 Git 中是完全独立的概念,所以你的命令没有意义。标签仅链接到提交,并且是存储库范围的。
Both tags and branches are references, think about tags as fixed references to a commit, and branches as moving references on the tip of a commits' branch.
标签和分支都是引用,将标签视为对提交的固定引用,将分支视为提交分支尖端的移动引用。
If the commit tagged v2.0.1
is already in the v2.0
branch I'd say you only have to push both to origin
. If not, you'll want to merge the branch containing the tag into the v2.0
branch, and push both.
如果标记的提交v2.0.1
已经在v2.0
分支中,我会说你只需要将两者都推送到origin
. 如果没有,您需要将包含标签的v2.0
分支合并到分支中,并同时推送两者。
回答by herbertD
If you push a lightweight tag, you should add the privilege 'Create Reference' for the reference name refs/tags/*
, because as CharlesB said, both tags and branches are references.
如果推送轻量级标签,则应该为引用名称添加权限“创建引用” refs/tags/*
,因为正如 CharlesB 所说,标签和分支都是引用。
After adding the 'Create Reference' right, you can use git push --tags
to push lightweight tags.
添加“创建引用”权限后,即可用于git push --tags
推送轻量级标签。