惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

M
MIT News - Artificial intelligence
有赞技术团队
有赞技术团队
S
Schneier on Security
aimingoo的专栏
aimingoo的专栏
T
Troy Hunt's Blog
U
Unit 42
Hacker News - Newest:
Hacker News - Newest: "LLM"
V2EX - 技术
V2EX - 技术
T
The Blog of Author Tim Ferriss
V
Visual Studio Blog
H
Heimdal Security Blog
H
Hacker News: Front Page
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Cloudbric
Cloudbric
Google DeepMind News
Google DeepMind News
C
Cisco Blogs
The Cloudflare Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
MyScale Blog
MyScale Blog
F
Fortinet All Blogs
N
News | PayPal Newsroom
Attack and Defense Labs
Attack and Defense Labs
D
DataBreaches.Net
N
News and Events Feed by Topic
Security Archives - TechRepublic
Security Archives - TechRepublic
Forbes - Security
Forbes - Security
Simon Willison's Weblog
Simon Willison's Weblog
F
Full Disclosure
The Register - Security
The Register - Security
L
LINUX DO - 热门话题
Webroot Blog
Webroot Blog
Google Online Security Blog
Google Online Security Blog
AI
AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
I
Intezer
S
Security Affairs
阮一峰的网络日志
阮一峰的网络日志
K
Kaspersky official blog
云风的 BLOG
云风的 BLOG
博客园 - 叶小钗
T
Threatpost
Spread Privacy
Spread Privacy
小众软件
小众软件
AWS News Blog
AWS News Blog
S
Secure Thoughts
S
Security @ Cisco Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
J
Java Code Geeks

vivaxy's Blog

SameSite Cookies 解读 - vivaxy's Blog VSCode Conventional Commits 插件 - vivaxy's Blog VSCode Conventional Commits Extension - vivaxy's Blog How Babel Is Built - vivaxy's Blog 一步一步解码 PNG 图片 - vivaxy's Blog Babel 的工程化实现 - vivaxy's Blog 浏览器图像转换手册 - vivaxy's Blog Decoding A PNG Image with JavaScript Step by Step Comprehensive Image Processing on Browsers Use npm Registry to Restric Installing Client Alfred 4 Workflow Open in VSCode 基于 Custom Elements 的组件化开发 - vivaxy's Blog JavaScript PNG 图片编码和解码 - vivaxy's Blog 如何在多个模块中共享异步数据 - vivaxy's Blog JavaScript 函数式编程初窥 - vivaxy's Blog 用纯 CSS 实现弹窗 - vivaxy's Blog 在浏览器中使用 JavaScript 模块 - vivaxy's Blog Karabiner Elements Hyper 改键设置 - vivaxy's Blog Levenshtein 距离 - vivaxy's Blog Levenshtein 距离 - vivaxy's Blog
Git Tag And Push Git Tag
vivaxy · 2019-08-02 · via vivaxy's Blog
  • Why my git tags cannot be pushed sometimes?
  • What’s the difference between git push --follow-tags and git push --tag?

There are concepts beneath the questions. Firstly, We will talk about lightweight tag and annotated tag.

Lightweight Tag And Annotated Tag.

Quote from Git - Tagging

Git supports two types of tags: lightweight and annotated.

A lightweight tag is very much like a branch that doesn’t change — it’s just a pointer to a specific commit.

Annotated tags, however, are stored as full objects in the Git database. They’re checksummed; contain the tagger name, email, and date; have a tagging message; and can be signed and verified with GNU Privacy Guard (GPG). It’s generally recommended that you create annotated tags so you can have all this information; but if you want a temporary tag or for some reason don’t want to keep the other information, lightweight tags are available too.

As we can see, annotated tags are the tags that matter. They should be taking good care of.

How To Tag?

git tag <tagname>                 => lightweight tag
git tag -a <tagname>              => annotated tag, will prompt for mesage
git tag -a -m <msg> <tagname>     => annotated tag
git tag -m <msg> <tagname>        => annotated tag

What Does npm version Do?

npm version will tag package versions like this:

Quote from cli/version.js · npm/cli

// ...
const flagForTag = signTag ? '-sm' : '-m'
// ...
stagePackageFiles(localData, options).then(() => {
  return git.exec(commitArgs, options)
}).then(() => {
  if (!localData.existingTag) {
    return git.exec([
      'tag', npm.config.get('tag-version-prefix') + version,
      flagForTag, message
    ], options)
  }
}).nodeify(cb)
// ...

It is an annotated tag.

So How Do We Push Tags?

There are two ways of pushing tags:

  • git push --follow-tags
  • git push --tags

Quote from How do you push a tag to a remote repository using Git? - Stack Overflow

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:

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

How do we push tags? git push --follow-tags!

In Conclusion

When you can’t push tags, you probably:

  • are using a lightweight tag, and git push --follow-tags.

While you can push tags, you probably:

  • are using a lightweight tag, and git push --tags. (Not recommended!)
  • are using an annotated tag, and git push --follow-tags.

Reference