git中的HEAD是什么? [英] What is the HEAD in git?

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

问题描述



什么是HEAD,什么是可以的我对它做了什么,应该避免什么错误? HEAD是对当前检出的最后一次提交的引用分支。




这是一个小例外,它是分离的HEAD。每当您签出一个 commit (或tag)而不是一个分支时,一个分离的HEAD 就是您最终遇到的情况。在这种情况下,您必须将其想象为没有名称的临时分支;所以我们只有 具有HEAD,而不是具有命名的分支引用。它仍然允许你进行提交(它会更新HEAD),所以如果你想把一个分离的HEAD作为一个没有名字的临时分支,上面的简短定义仍然是正确的。


There seems to be a difference between the last commit, the HEAD and the state of the file I can see in my directory.

What is HEAD, what can I do with it and what mistake should I avoid?

解决方案

HEAD is a reference to the last commit in the currently checked-out branch.


There is a small exception to this, which is the detached HEAD. A detached HEAD is the situation you end up in whenever you check out a commit (or tag) instead of a branch. In this case, you have to imagine this as a temporary branch without a name; so instead of having a named branch reference, we only have HEAD. It will still allow you to make commits (which will update HEAD), so the above short definition is still true if you think of a detached HEAD as a temporary branch without a name.

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

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