在git show-ref -d的背景下什么是取消引用 [英] what is dereference in the context of git show-ref -d

查看:132
本文介绍了在git show-ref -d的背景下什么是取消引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是 git show-ref -d 的手册页。他们在底部也有一个例子。仍然我无法理解什么是解除引用?

解决方案

在git中,正常(带注释的,不是轻量级的)标签本身就是一个对象,包含元数据和它所标记的对象的SHA1。有关 git对象模型的git社区书中有一张漂亮的图片(scroll所以,当你在普通标签上使用show-ref时,它通常会给你关于标签对象的信息。使用 -d / - 取消引用选项,它会将标记取消引用到标记引用的对象中,并提供有关它的信息。



关于轻量级标签和注释标签的注释,如果您不知道:使用 git tag< tag name> (即没有任何元数据提供选项,如 -a -s -u )。它根本不是标签对象,只是一个直接指向已标记对象的参考。如果您提供了其中一个选项,那么您将元数据附加到标记上,所以git会创建一个标记对象来保存它。


Here is the man page for git show-ref -d . They also have an example at the bottom. Still I am not able to understand what dereference does?

解决方案

In git, a "normal" (annotated, not lightweight) tag is an object unto itself, containing metadata and the SHA1 of the object it tags. There's a pretty picture in the section of the git community book on the git object model (scroll to the bottom).

So, when you use show-ref on a normal tag, it will normally give you information about the tag object. With the -d/--dereference option, it will dereference the tag into the object the tag refers to, and provide information about it instead.

And a note on lightweight vs. annotated tags, in case you aren't aware of that: a lightweight tag is created by using git tag <tag name> (i.e. without any of the metadata-providing options like -a, -s, or -u). It's not a tag object at all, just a ref pointing straight to the object you've tagged. If you provide one of those options, you're attaching metadata to the tag, so git creates a tag object to hold that.

这篇关于在git show-ref -d的背景下什么是取消引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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