“git push”和“git push --tags”在同一个命令中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19404436/
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
"git push" and "git push --tags" in the same command?
提问by Nicolas Raoul
I usually run:
我通常运行:
git push
git tag v4.7
git push --tags
Both the first and third operations connect to the server, which wastes time.
I want to make it faster by pushing only once. What command(s) would achieve this?
It is in a bash script, and needs to run fine in any branch, not just master
.
第一个和第三个操作都连接到服务器,浪费时间。
我想通过只推一次来让它更快。什么命令可以实现这一点?
它位于 bash脚本中,需要在任何分支中正常运行,而不仅仅是master
.
Reading the manual, I don't think git push all
is the solution:
阅读手册,我认为不是git push all
解决方案:
--all: Instead of naming each ref to push, specifies that all refs under refs/heads/ be pushed.
--tags: All refs under refs/tags are pushed, in addition to refspecs explicitly listed on the command line.
--all:不是将每个引用命名为推送,而是指定推送 refs/heads/ 下的所有引用。
--tags:除了在命令行中明确列出的 refspecs 之外,refs/tags 下的所有 refs 都被推送。
回答by Kornel
The closest option may be:
最接近的选项可能是:
git push --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 committish that are reachable from the refs being pushed.
推送所有将在没有此选项的情况下推送的引用,并推送远程缺少但指向可从被推送的引用访问的 committish 中的注释标签。
回答by Daniel Hilgarth
According to the documentation of --tags
you can specify additional refspecs to be pushed.
根据您的文档,--tags
您可以指定要推送的其他参考规范。
So you can simply use
所以你可以简单地使用
git push --tags origin HEAD
回答by Volen
You can create alias to have a fast access to this command:
您可以创建别名以快速访问此命令:
git config --global alias.p '!git push && git push --tags'
or
或者
git config --global alias.pa '!git push --all && git push --tags'
now you can do it like this:
现在你可以这样做:
git tag v4.7
git p
You can read more about aliases here
您可以在此处阅读有关别名的更多信息