开发者

Git remote origin has two branches

开发者 https://www.devze.com 2023-04-07 14:04 出处:网络
I am using TortoiseGit for Windows. I see two branches on remote/origi开发者_如何学JAVAn: HEAD20 minutes agoSome commit message.

I am using TortoiseGit for Windows. I see two branches on remote/origi开发者_如何学JAVAn:

HEAD        20 minutes ago      Some commit message.
master      20 minutes ago      Some commit message.

I am confused why HEAD shows up as a branch; I did not explicitly create a separate branch on origin - it should only be 'master'. It's not really a problem, since they seem to update together anyway.

If I execute git branch on origin, it only shows 'master'.

Why are there two branches? Is this a TortoiseGit-specific thing, or a Git-specific thing? Thanks!


It's a git-specific thing. HEAD is a reference to the currently checked out thing, i.e. usually a branch. In your case, HEAD is simply an alias for master. TortoiseGit apparently can't tell an alias ("symbolic ref") from a normal branch, so it appears as if HEAD is an extra branch when it really isn't.

The situation is a bit different for remote repositories which usually don't have anything checked out at all. You seem to be looking at a remote repository here. In that case, that repository's HEAD is used to determine which branch is checked out by default when someone clones that repository. That's why, when you clone, some branch or another is checked out: git doesn't just randomly pick a branch, but it looks at the source repository's HEAD to make that decision.


HEAD is the current revision. It's best answered by this question right here. It will be exactly the same as the currently checked out ref.


HEAD is the current "head" of the remote repo and would usually be same as the master. It is the current checked out branch / ref and is from the .git/HEAD file in the repo which has content like:

ref: refs/heads/master
0

精彩评论

暂无评论...
验证码 换一张
取 消