git ORIG_HEAD、FETCH_HEAD、MERGE_HEAD 等

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17595524/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 16:31:58  来源:igfitidea点击:

ORIG_HEAD, FETCH_HEAD, MERGE_HEAD etc

git

提问by takeshin

There's a lot of useful git references (what is the exact name for this?), e.g. HEAD, ORIG_HEAD, FETCH_HEAD, MERGE_HEAD, @{upstream} etc.

有很多有用的 git 引用(它的确切名称是什么?),例如HEAD, ORIG_HEAD, FETCH_HEAD, MERGE_HEAD, @{upstream} 等。

Is there any reference for this? A complete list with explanations?

有没有这方面的参考?一个完整的列表和解释?

回答by dahlbyk

git help revisionsbrings up http://git-scm.com/docs/gitrevisions, which describes all thethe most common ways to reference commits:

git help revisions提出了http://git-scm.com/docs/gitrevisions,它描述了一切引用提交的最常见方法:

  • HEADnames the commit on which you based the changes in the working tree.
  • FETCH_HEADrecords the branch which you fetched from a remote repository with your last git fetch invocation.
  • ORIG_HEADis created by commands that move your HEADin a drastic way, to record the position of the HEADbefore their operation, so that you can easily change the tip of the branch back to the state before you ran them.
  • MERGE_HEADrecords the commit(s) which you are merging into your branch when you run git merge.
  • CHERRY_PICK_HEADrecords the commit which you are cherry-picking when you run git cherry-pick.
  • HEAD命名您基于工作树中的更改的提交。
  • FETCH_HEAD记录您使用上次 git fetch 调用从远程存储库中获取的分支。
  • ORIG_HEADHEAD以剧烈方式移动您的命令创建,以记录HEAD它们操作之前的位置,以便您可以轻松地将分支的尖端更改回运行它们之前的状态。
  • MERGE_HEAD记录运行 git merge 时合并到分支中的提交。
  • CHERRY_PICK_HEAD当您运行 git cherry-pick 时,记录您正在挑选的提交。

From the git source, you can also find out about BISECT_HEAD, REVERT_HEAD, REJECT_NON_FF_HEADand several others that you will almost certainly never need.

从git的来源,你也可以了解BISECT_HEADREVERT_HEADREJECT_NON_FF_HEAD和其他几个人,你几乎肯定会永远需要。

That reference also explains suffixes (^N, ~N, @{...}), ranges (..vs ...), and more.

该参考还解释了后缀 ( ^N, ~N, @{...})、范围 ( ..vs ...) 等。

回答by Sergey K.

HEAD: The current ref that you're looking at. In most cases it's probably refs/heads/master

HEAD:您正在查看的当前参考。大多数情况下可能是refs/heads/master

FETCH_HEAD: The SHAs of branch/remote heads that were updated during the last git fetch

FETCH_HEAD:上次更新的分支/远程头的 SHA git fetch

ORIG_HEAD: When doing a merge, this is the SHA of the branch you're merging into.

ORIG_HEAD:进行合并时,这是您要合并到的分支的 SHA。

MERGE_HEAD: When doing a merge, this is the SHA of the branch you're merging from.

MERGE_HEAD:进行合并时,这是您要合并的分支的 SHA。

CHERRY_PICK_HEAD: When doing a cherry-pick, this is the SHA of the commit which you are cherry-picking.

CHERRY_PICK_HEAD:在进行挑选时,这是您挑选的提交的 SHA。

The complete list of these refs can be found by cloning git sources:

可以通过克隆 git 源找到这些参考的完整列表:

git clone https://github.com/git/git.git

git clone https://github.com/git/git.git

and grepping the _HEAD"string in .cfiles. They are dispersed all over the place, but still can be easily found.

_HEAD".c文件中搜索字符串。它们分散在各处,但仍然很容易找到。

P.S.

聚苯乙烯

git help revisionsdoes not show the list of all possible named refs.

git help revisions不显示所有可能的命名引用的列表。

回答by Sergey K.

This is what the official Linux Kernel Git documentation for Git revisionssays:

这是Git 修订版官方 Linux 内核 Git 文档所说的:

HEADnames the commit on which you based the changes in the working tree.

FETCH_HEADrecords the branch which you fetched from a remote repository with your last git fetch invocation.

ORIG_HEADis created by commands that move your HEADin a drastic way, to record the position of the HEADbefore their operation, so that you can easily change the tip of the branch back to the state before you ran them.

MERGE_HEADrecords the commit(s) which you are merging into your branch when you run git merge.

CHERRY_PICK_HEADrecords the commit which you are cherry-picking when you run git cherry-pick.

HEAD命名您基于工作树中的更改的提交。

FETCH_HEAD记录您使用上次 git fetch 调用从远程存储库中获取的分支。

ORIG_HEADHEAD以剧烈方式移动您的命令创建,以记录HEAD它们操作之前的位置,以便您可以轻松地将分支的尖端更改回运行它们之前的状态。

MERGE_HEAD记录运行 git merge 时合并到分支中的提交。

CHERRY_PICK_HEAD当您运行 git cherry-pick 时,记录您正在挑选的提交。

Also, for @{upstream}:

此外,对于@{upstream}

<refname>@{upstream}, e.g. master@{upstream}, @{u}

The suffix @{upstream}to a ref (short form <refname>@{u}) refers to the branch the ref is set to build on top of. A missing ref defaults to the current branch.

<refname>@{upstream},例如master@{upstream}@{u}

@{upstream}ref的后缀(简称<refname>@{u})指的是 ref 设置在其上构建的分支。缺少的 ref 默认为当前分支。

回答by usumoio

These references are called pointers. They are just regular pointers in programmer terms to tree-ish entities that exist within Git. Note that a tree-ish is anything that consists of at least one commit, i.e. a branch, tag, stash or something like HEAD. Regarding a complete list, I think the only one that exists is the manual:

这些引用称为指针。它们只是程序员术语中指向存在于 Git 中的树状实体的常规指针。请注意,树形树是至少包含一次提交的任何内容,即分支、标签、存储或类似的东西HEAD。关于完整列表,我认为唯一存在的是手册:

http://git-scm.com/documentation

http://git-scm.com/documentation

While there is no complete list of the available special pointers like HEADThe manual does cover the complete list of available pointers therein, although they are kind of hard to find.

虽然没有像HEADThe manual 这样的可用特殊指针的完整列表,但确实涵盖了其中可用指针的完整列表,尽管它们很难找到。