Git 中的 HEAD 和 ORIG_HEAD [英] HEAD and ORIG_HEAD in Git

查看:35
本文介绍了Git 中的 HEAD 和 ORIG_HEAD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这些符号指的是什么?它们是什么意思?

What do these symbols refer to and what do they mean?

(我在官方文档中找不到任何解释)

(I can't find any explanation in official documentation)

推荐答案

HEAD 是(直接或间接,即符号)对当前提交的引用.这是您已在工作目录中签入的提交(除非您进行了一些更改或等效),并且它是在git commit"之上的提交.会做一个新的.通常 HEAD 是对其他命名分支的符号引用;此分支当前是签出分支,或当前分支.HEAD 也可以直接指向一个提交;这种状态称为分离的 HEAD",可以理解为在未命名的匿名分支上.

HEAD is (direct or indirect, i.e. symbolic) reference to the current commit. It is a commit that you have checked in the working directory (unless you made some changes, or equivalent), and it is a commit on top of which "git commit" would make a new one. Usually HEAD is symbolic reference to some other named branch; this branch is currently checked out branch, or current branch. HEAD can also point directly to a commit; this state is called "detached HEAD", and can be understood as being on unnamed, anonymous branch.

@ 单独是 HEAD 的快捷方式,因为 Git 1.8.5

And @ alone is a shortcut for HEAD, since Git 1.8.5

ORIG_HEADHEAD 之前的状态code>,由可能具有危险行为的命令设置,以便于恢复它们.现在 Git 有 reflog 不太有用:HEAD@{1} 大致相当于 ORIG_HEAD(HEAD@{1} 总是最后HEAD的值,ORIG_HEAD是危险操作前HEAD的最后一个值.

ORIG_HEAD is previous state of HEAD, set by commands that have possibly dangerous behavior, to be easy to revert them. It is less useful now that Git has reflog: HEAD@{1} is roughly equivalent to ORIG_HEAD (HEAD@{1} is always last value of HEAD, ORIG_HEAD is last value of HEAD before dangerous operation).

欲了解更多信息,请阅读 git(1) 手册页/[gitrevisions(7) manpage][git-revisions], Git 用户手册Git 社区手册Git 词汇表

For more information read git(1) manpage / [gitrevisions(7) manpage][git-revisions], Git User's Manual, the Git Community Book and Git Glossary

这篇关于Git 中的 HEAD 和 ORIG_HEAD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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