什么是“at”? @符号/符号/字符在Git中意味着什么? [英] What does the "at" @ sign/symbol/character mean in Git?

查看:217
本文介绍了什么是“at”? @符号/符号/字符在Git中意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

@ 通常用于git中以不同的
方式指定修订版本
。例如,


  1. < ref> @ {< date>}



    > git diff master @ {yesterday} master


  2. < ref> @ {< n>例如: git diff 特定于前一个状态的参考。

    master @ {1} master


  3. @ { - < n>}


    示例:指定前一个检出分支。 > git checkout @ { - 5}


  4. < 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 的含义:


  1. Git中的HEAD和ORIG_HEAD a>。

  2. 什么是git HEAD,正好?

VonC还找到了有关为什么选择 @ 的有趣信息作为的快捷方式这个堆栈溢出答案(底部的最后一部分)


The at-sign @ is often used in git to specify revisions in different ways. For example,

  1. <ref>@{<date>} specifies the reference at its state on <date>.

    Example: git diff master@{yesterday} master.

  2. <ref>@{<n>} specific the reference at its nth prior state.

    Example: git diff master@{1} master.

  3. @{-<n>} specifies the nth previously checked-out branch before the current one.

    Example: git checkout @{-5}.

  4. <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:

  1. HEAD and ORIG_HEAD in Git.
  2. What is git HEAD, exactly?.

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屋!

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