Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
709 views
in Technique[技术] by (71.8m points)

git - Difference between HEAD and master

What is the difference between the HEAD and master in Git?

I did a clone of a project on GitHub and want to push my changes to the remote. But to which one should I push?

screenshot

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

master is a reference to the end of a branch. By convention (and by default) this is usually the main integration branch, but it doesn't have to be.

HEAD is actually a special type of reference that points to another reference. It may point to master or it may not (it will point to whichever branch is currently checked out). If you know you want to be committing to the master branch then push to this.

Here is a visual example:

alt text

On your own repository you can check where the HEAD is pointing to by running this:

$ git symbolic-ref HEAD
refs/heads/master

However, finding out where the remotes/origin/HEAD is pointing to is more tricky because it is on the remote machine.

There is a great little tutorial on git references here:

http://people.gnome.org/~federico/news-2008-11.html#pushing-and-pulling-with-git-1


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...