如何使用Git将标签推送到远程存储库? [英] How do you push a tag to a remote repository using Git?

查看:98
本文介绍了如何使用Git将标签推送到远程存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将远程Git存储库克隆到了我的笔记本电脑,然后我想添加一个标签,以便我运行

I have cloned a remote Git repository to my laptop, then I wanted to add a tag so I ran

git tag mytag master

当我在笔记本电脑上运行git tag时,将显示标记mytag.然后,我想将其推送到远程存储库,以便在所有客户端上都具有此标记,因此我运行git push,但收到消息:

When I run git tag on my laptop the tag mytag is shown. I then want to push this to the remote repository so I have this tag on all my clients, so I run git push but I got the message:

所有最新信息

Everything up-to-date

如果我转到桌面并运行git pull,然后运行git tag,则不会显示任何标签.

And if I go to my desktop and run git pull and then git tag no tags are shown.

我还尝试过对项目中的文件进行较小的更改,然后将其推送到服务器.之后,我可以将更改从服务器拉到台式计算机,但是在台式计算机上运行git tag时仍然没有标签.

I have also tried to do a minor change on a file in the project, then push it to the server. After that I could pull the change from the server to my Desktop computer, but there's still no tag when running git tag on my desktop computer.

如何将标签推送到远程存储库,以便所有客户端计算机都可以看到它?

How can I push my tag to the remote repository so that all client computers can see it?

推荐答案

git push --follow-tags

git push --follow-tags

这是Git 1.8.3中引入的明智选择:

This is a sane option introduced in Git 1.8.3:

git push --follow-tags

它既推送提交,也推送全部都是的标签:

It pushes both commits and only tags that are both:

  • 带注释的
  • 从提交中
  • 可达(祖先)

这是理智的,因为:

出于这些原因,应避免使用--tags.

It is for those reasons that --tags should be avoided.

Git 2.4 已添加 push.followTags选项以默认打开该标志您可以设置:

Git 2.4 has added the push.followTags option to turn that flag on by default which you can set with:

git config --global push.followTags true

,或在~/.gitconfig文件的[push]部分中添加followTags = true.

or by adding followTags = true to the [push] section of your ~/.gitconfig file.

这篇关于如何使用Git将标签推送到远程存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆