[英]Why are git private tags and associated private code uploaded to public repositories?
I maintained a git tree which contained numerous branches, some private and some pushed to a public repository at bitbucket. 我维护了一个git树,其中包含许多分支,有些是私有的,有些是推送到bitbucket上的公共存储库的。 I recently unintentionally discovered that if I tag commits in the private branches, then uploading tags with
我最近无意间发现,如果我在私有分支中标记提交,则使用
git push --tags
leads to all the commits in the private branch and the private tags being uploaded as a dangling tag. 导致将私有分支中的所有提交和私有标签作为悬挂标签上载。 This exposed a whole lot of private code that was never intended to be public, leading to me deleting the whole repository and re-uploading it without the offending tags to try and fix the issue.
这暴露了很多从未公开的私人代码,导致我删除了整个存储库并重新上传它,而没有令人讨厌的标签来尝试解决此问题。
I've created a sample git tree with only 2 public commits and one private commit in a separate private branch showing how pushing tags pushed the private tag and associated private commit here: https://bitbucket.org/ckolivas/testtag/commits/all PU1 and PU2 were tags made on the master branch and PR1 a tag made on the private branch. 我在一个单独的私有分支中创建了一个仅包含2个公共提交和一个私有提交的示例git树,在此处显示了推送标签如何将私有标签和相关的私有提交推送: https : //bitbucket.org/ckolivas/testtag/commits/所有 PU1和PU2都是在主分支上创建的标签,而PR1是在私有分支上创建的标签。
Is this the correct behaviour that wanting to push tags will make it push ALL the tags, even if they're not part of master? 这是否是要推送标签的正确行为,即使它们不是主服务器的一部分,也要使其推送所有标签? It seems counter-intuitive to me.
对我来说似乎违反直觉。
Is this the correct behaviour that wanting to push tags will make it push ALL the tags, even if they're not part of master?
这是否是要推送标签的正确行为,即使它们不是主服务器的一部分,也要使其推送所有标签? It seems counter-intuitive to me.
对我来说似乎违反直觉。
Tags has nothing to do with master or any other branch. 标签与master或任何其他分支无关。 Tags are simply reference to a commit and indeed you "load" them to the remote using the ``push --tags`
标签只是对提交的引用,实际上,您可以使用“ push --tags”将其“加载”到远程
"Private" branches are local branches which are not published to remote repository. “私人”分支是本地分支,不会发布到远程存储库。
"Public" branches are branches in the remote repository. “公共”分支是远程存储库中的分支。
If you use tags prefer the annotated tag git tag -a
over the "regular tag" git tag
. 如果使用标签,则首选带注释的标签
git tag -a
而不是“常规标签” git tag
。 It will create annotated tag with the same info as commit so you can view it later on. 它将创建带有与提交相同信息的带注释的标记,以便您以后可以查看它。
From the git push documentation: 从git push文档中:
git push --follow-tags
You can also use the git push --follow-tags
to push all your tags 您还可以使用
git push --follow-tags
推送所有标签
--follow-tags
-关注标签
Push all the refs that would be pushed without this option, and also push annotated tags in refs/tags that are missing from the remote but are pointing at commit-ish that are reachable from the refs being pushed.
推送所有不带此选项将被推送的ref,并推送带注释的标签到远程丢失的ref / tag中,但指向被推送的ref可以到达的commit-ish。
This can also be specified with configuration variable
push.followTags
.也可以使用配置变量
push.followTags
进行指定。
For more information, seepush.followTags
in git-config .有关更多信息,请参见git-config中的
push.followTags
。--tags
-标签
All refs under
refs/tags
are pushed, in addition to refspecs explicitly listed on the command line.除了在命令行上明确列出的refspecs之外,还会推送
refs/tags
下的所有refs。
This is the correct bahaviour, since you are uploading all
tags. 这是正确的行为,因为您正在上传
all
标签。 If you wish to only upload tags associated with some "public" branches, then list those tags explicitly, like 如果您只想上传与某些“公共”分支关联的标签,则可以明确列出这些标签,例如
git push some_remote some_public_tag
Fom the documentation for git push
: 提供
git push
的文档 :
--tags
All refs under
refs/tags
are pushed, in addition to refspecs explicitly listed on the command line.除了在命令行上明确列出的refspecs之外,还会推送
refs/tags
下的所有refs。
So, yes, git push --tags
pushes all tags. 所以,是的,
git push --tags
推送所有标签。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.