什么是“at”? @符号/符号/字符在Git中意味着什么? [英] What does the "at" @ sign/symbol/character mean in Git?
问题描述
@
通常用于git中以不同的方式指定修订版本。例如,
-
< ref> @ {< date>} $ c $例如:
> git diff master @ {yesterday} master 。 -
< ref> @ {< n>例如:
git diff 特定于前一个状态的参考。
-
@ { - < n>} $ c
示例:
指定前一个检出分支。 > git checkout @ { - 5}
。 -
< ref> code>指定引用的上游分支。
示例:
git diff master {{upstream} master
然而, @
在git命令中也以其他方式使用,比如
git rebase -i @〜4
git log @ ^^ .. @
在这些例子中,符号 @
意味着什么?
自Git 1.8.5版开始,符号 @
,没有前导分支/引用名称和序号 {n}
后缀类似于 HEAD @ {1}
和 master @ {1}
,只是特殊Git引用的同义词/别名/快捷方式 HEAD
:
现在不用键入四个大写字母HEAD,您可以说@,例如git log @。
所以对于这些命令
git rebase -i @〜4
git log @ ^^ .. @
你可以简单地用 HEAD
替换第一个 出现的 @
或 head
,如果使用Windows或OS X的话)
git rebase -i HEAD〜4
git log HEAD ^^ .. HEAD
那么 HEAD
是什么意思?正如官方Linux Kernel Git文档中所述,用于指定Git修订版, HEAD
是一个特殊的快捷方式参考,您目前已将其作为工作副本签出(或者以Git方式,即工作树) :
$ b
HEAD命名您在工作树中基于更改的提交。
您还可以阅读这些其他堆栈溢出问题,以了解特殊引用 HEAD
的含义:
VonC还找到了有关为什么选择 @
的有趣信息作为头
的快捷方式这个堆栈溢出答案(底部的最后一部分)。
The at-sign @
is often used in git to specify revisions in different
ways. For example,
<ref>@{<date>}
specifies the reference at its state on<date>
.Example:
git diff master@{yesterday} master
.<ref>@{<n>}
specific the reference at its nth prior state.Example:
git diff master@{1} master
.@{-<n>}
specifies the nth previously checked-out branch before the current one.Example:
git checkout @{-5}
.<ref>@{upstream}
specifies the upstream branch for the reference.Example:
git diff master@{upstream} master
.
However, the @
is being used in other ways in git commands too, like
git rebase -i @~4
git log @^^..@
What does the at-sign @
mean in those examples?
As of Git version 1.8.5, the at-sign @
, without a leading branch/reference name and ordinal {n}
suffix like HEAD@{1}
and master@{1}
, is just a synonym/alias/shortcut for the special Git reference HEAD
:
Instead of typing four capital letters "HEAD", you can say "@" now, e.g. "git log @".
So for these commands
git rebase -i @~4
git log @^^..@
you can simply substitute the first occurrence of @
with HEAD
(or head
if using Windows or OS X)
git rebase -i HEAD~4
git log HEAD^^..HEAD
So what does HEAD
mean? As explained by the official Linux Kernel Git documentation for specifying Git revisions, HEAD
is a special shortcut reference for the commit that you currently have checked-out as your working copy (or in Git terms, your "working tree"):
HEAD names the commit on which you based the changes in the working tree.
You can also read these other Stack Overflow questions on what the special reference HEAD
means:
VonC also found interesting information about why @
was chosen as a shortcut for head
in this Stack Overflow answer (the last section at the bottom).
这篇关于什么是“at”? @符号/符号/字符在Git中意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!