问题描述
在我学习git的时候,我总是碰到HEAD,master,origin的术语,我不确定它们有什么不同。如果我理解正确,HEAD总是等于最新版本?如果是这样,是整个存储库或特定分支或标签的最新版本?这很混乱。我已经阅读了很多这方面的教程和分支/合并之类的东西,但是仍然无法将它包裹起来。
我强烈推荐Scott Chacon 。花点时间,真正阅读它,同时探索实际的git回购。
HEAD :当前提交回购。大部分时间 HEAD
指向分支中的最新提交,但不一定如此。 HEAD
真的意味着我的回购目前指向什么。
如果提交 HEAD
指的不是任何分支的尖端,这称为分离头部。
主:git在首次创建回购时为您创建的默认分支的名称。在大多数情况下,主意味着主分支。大多数商店都有人推动掌握,而主人被认为是回购的权威观点。但是释放分支从主分离释放也很常见。您的本地回购有其自己的主分支,几乎总是遵循远程回购的主人。
原产地:git给出的默认名称到您的主要远程回购。你的盒子有自己的回购,并且你很可能推出一些你和你的同事推动的远程回购。该远程回购几乎总是被称为原产地,但它不一定是。
HEAD
是一位官员git中的概念。 HEAD
总是有明确的含义。 master
和 origin
是通常在git中使用的常用名称,但不一定是。
As I'm learning about git, I keep coming across the terms HEAD, master, origin, and I'm not sure what the differences are. If I understand correctly, HEAD is always equal to the latest revision? And if so, is that the latest revision of the whole repository, or of a specific branch or tag? This is so confusing. I've read so many tutorials on this and things like branching/merging, but still can't wrap my head around it.
I highly recommend the book "Pro Git" by Scott Chacon. Take time and really read it, while exploring an actual git repo as you do.
HEAD: the current commit your repo is on. Most of the time HEAD
points to the latest commit in your branch, but that doesn't have to be the case. HEAD
really just means "what is my repo currently pointing at".
In the event that the commit HEAD
refers to is not the tip of any branch, this is called a "detached head".
master: the name of the default branch that git creates for you when first creating a repo. In most cases, "master" means "the main branch". Most shops have everyone pushing to master, and master is considered the definitive view of the repo. But it's also common for release branches to be made off of master for releasing. Your local repo has its own master branch, that almost always follows the master of a remote repo.
origin: the default name that git gives to your main remote repo. Your box has its own repo, and you most likely push out to some remote repo that you and all your coworkers push to. That remote repo is almost always called origin, but it doesn't have to be.
HEAD
is an official notion in git. HEAD
always has a well-defined meaning. master
and origin
are common names usually used in git, but they don't have to be.
这篇关于HEAD,master,origin的git概念是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!