HEADis (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. UsuallyHEADis symbolic reference to some other named branch; this branch is currently checked out branch, or current branch.HEADcan also point directly to a commit; this state is called "detached HEAD", and can be understood as being on unnamed, anonymous branch.
ORIG_HEADis previous state ofHEAD, 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 toORIG_HEAD(HEAD@{1}is always last value ofHEAD,ORIG_HEADis last value ofHEADbefore dangerous operation).
For more information readgit(1) manpage,Git User's Manual, theGit Community BookandGit Glossary
A head is simply a reference to a commit object. Each head has a name (branch name or tag name, etc). By default, there is a head in every repository called master. A repository can contain any number of heads. At any given time, one head is selected as the “current head.” This head is aliased to HEAD, always in capitals".
Note this difference: a “head” (lowercase) refers to any one of the named heads in the repository; “HEAD” (uppercase) refers exclusively to the currently active head. This distinction is used frequently in Git documentation.
本文介绍了Git中HEAD和ORIG_HEAD的作用与区别。HEAD指向当前工作目录中的提交,通常与某个分支关联;而ORIG_HEAD则记录了HEAD在进行潜在危险操作前的状态,便于撤销操作。文章还解释了Git中的引用概念。
1353

被折叠的 条评论
为什么被折叠?



