推git提交&同时标记 [英] Push git commits & tags simultaneously
问题描述
我意识到 git push --tags
是一个单独的操作,它对普通的旧的 git push
。推送标签应该是有意识的选择,因为您不想意外推送标签。没关系。但是有没有办法将两者联系在一起? (除了 git push&& git push --tags
。)
2015年5月更新
截至 git 2.4.1 ,你可以这样做:
git config --global push.followTags true
如果设置为true,默认启用--follow-tags选项。您可以在推送时通过指定--no-follow-tags来覆盖此配置。
2013年4月更新
由于 git 1.8.3(2013年4月22日),您不必再执行2个命令来推送分支,然后推送标签:
新的
- follow-tags
选项告诉git push
to 推送分支时推送相关的注释标签。
现在您可以尝试,推送新提交时:
git push --follow-tags
虽然不会全部推送所有本地标签,只有通过 Git 2.4.1+(2015年第二季度)将推出
push.followTags $ git 。
c $ c>:参见如何让<
原始答案,2010年9月
核选项是 git push --mirror
,它会将下的所有ref都推送出去。
您也可以只推送一个标签与您当前的分支提交:
git push origin:v1.0.0
您可以将 - tags
选项与refspec结合使用,如:
git push origin --tags:
(因为 您也有此条目推送分支和标签 一个方便的提示只发布到 Git邮件列表ZoltánFüzesi: 我使用 添加 还没有尝试过,但看起来它可能有用,直到其他方式推送分支和标签的同时被添加到git push。 当心,如评论 Aseem Kishore 这只是我刚刚的,所以仅供参考。 I'm aware of the reason that As of git 2.4.1, you can do
If set to true enable --follow-tags option by default. You may override this configuration at time of push by specifying --no-follow-tags.
Since git 1.8.3 (April 22d, 2013), you no longer have to do 2 commands to push branches, and then to push tags: The new " You can now try, when pushing new commits: That won't push all the local tags though, only the one referenced by commits which are pushed with the Git 2.4.1+ (Q2 2015) will introduce the option The nuclear option would be You can also push just one tag with your current branch commit: You can combine the (since You also have this entry "Pushing branches and tags with a single "git push" invocation" A handy tip was just posted to the Git mailing list by Zoltán Füzesi: I use
With these lines added Haven't tried it myself yet, but it looks like it might be useful until some other way of pushing branches and tags at the same time is added to git push.
Beware, as commented by Aseem Kishore This bit me just now, so FYI.
René Scheibe adds this interesting comment: The
这篇关于推git提交&同时标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! - tags
表示:所有在 refs / tags
下的ref都被推送, 除了在命令行中明确列出的refspecs之外)
.git / config
来解决这个问题:
[remote来源]
url = ...
fetch = + refs / heads / *:refs / remotes / origin / *
push = + refs / heads / *
push = + refs / tags / *
git push origin
会上传你的所有分支和标签。如果你只想上传其中的一部分,你可以枚举它们。
另一方面,我不介意输入:
$ git push&& git push --tags
$ b push = + refs / heads / *
will 强行推动所有分支机构。
- follow-tags
参数具有误导性,因为只有 .git / refs下的标签/ tags
被考虑。
如果运行 git gc
,标签将从 .git / refs / tags
到 .git / packed-refs
。之后 git push --follow-tags ...
无法按预期工作。
git push --tags
is a separate operation to plain old git push
. Pushing tags should be a conscious choice since you don't want accidentally push one. That's fine. But is there a way to push both together? (Aside from git push && git push --tags
.)Update May 2015
git config --global push.followTags true
Update April 2013
--follow-tags
" option tells "git push
" to push relevant annotated tags when pushing branches out.git push --follow-tags
git push
.push.followTags
: see "How to make "git push
" include tags within a branch?".Original answer, September 2010
git push --mirror
, which will push all refs under refs/
.git push origin : v1.0.0
--tags
option with a refspec like:git push origin --tags :
--tags
means: All refs under refs/tags
are pushed, in addition to refspecs explicitly listed on the command line)
.git/config
to solve this:[remote "origin"]
url = ...
fetch = +refs/heads/*:refs/remotes/origin/*
push = +refs/heads/*
push = +refs/tags/*
git push origin
will upload all your branches and tags. If you want to upload only some of them, you can enumerate them.
On the other hand, I don't mind typing:$ git push && git push --tags
push = +refs/heads/*
will force-pushes all your branches.
--follow-tags
parameter is misleading as only tags under .git/refs/tags
are considered.
If git gc
is run, tags are moved from .git/refs/tags
to .git/packed-refs
. Afterwards git push --follow-tags ...
does not work as expected anymore.