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

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

问题描述

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



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

解决方案

HEAD 是对当前提交的引用(直接或间接,即符号)。它是你在工作目录中检查的一个提交(除非你做了一些改变或者等价的),并且它是一个提交,其中git commit会做出一个新提交。通常 HEAD 是对其他某个命名分支的符号引用;这个分支目前被检出分支或当前分支。 HEAD 也可以直接指向提交;这个状态被称为detached HEAD,可以理解为匿名分支。



@

本身就是 HEAD 的快捷方式。 href =https://git-scm.com/docs/gitrevisions =noreferrer> ORIG_HEAD 是之前的状态 HEAD ,由具有可能危险行为的命令设置,以便于恢复它们。现在Git的reflog不太有用: HEAD @ {1} 大致等于 ORIG_HEAD HEAD @ {1} 始终是 HEAD的最后一个值, ORIG_HEAD 是在危险操作前 HEAD 的最后一个值)。 www.kernel.org/pub/software/scm/git/docs/git.htmlrel =noreferrer> git(1)手册页, Git使用手册 Git Community Book Git词汇表


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

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

解决方案

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.

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

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).

For more information read git(1) manpage, Git User's Manual, the Git Community Book and Git Glossary

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

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