如何使用 Git 将标签推送到远程存储库? [英] How do you push a tag to a remote repository using 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:
一切都是最新的
如果我转到我的桌面并运行 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 origin <tag_name>
并且以下命令应该推送所有标签(不推荐):
And the following command should push all tags (not recommended):
# not recommended
git push --tags
这篇关于如何使用 Git 将标签推送到远程存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!