2020年12月10日 星期四

[Git 常見問題] How do you push a tag to a remote repository using Git?

 Source From Here

Question
I have cloned a remote Git repository to my laptop, then I wanted to add a tag so I ran:
# git tag mytag master

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

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

HowTo
Try option "--follow-tags". 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:
* Annotated
* Reachable (an ancestor) from the pushed commits

This is sane because:
* you should only push annotated tags to the remote, and keep lightweight tags for local development to avoid tag clashes. See also: What is the difference between an annotated and unannotated tag?
* it won't push annotated tags on unrelated branches

It is for those reasons that --tags should be avoided. 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

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

Supplement
為你自己學 Git - 使用標籤

沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...