开发者

Git remote has master but no HEAD

开发者 https://www.devze.com 2022-12-22 04:13 出处:网络
I\'m new to Git, so I suspect that I\'m misunderstanding something here, but I\'ll ask anyway. Via TortoiseGit I do the following:

I'm new to Git, so I suspect that I'm misunderstanding something here, but I'll ask anyway.

Via TortoiseGit I do the following:

  • Init a new Git repo locally
  • Add a readme file to it and commit
  • Add a new remote
  • Push the new repo to the orgin (remote)

If I then Browse Refs I see the following:

heads/master

remotes/origin/master

What I find odd is that I don't see a HEAD on the r开发者_运维技巧emotes.

If I delete my local repo and then clone it from the server (I just pushed to above) and then browse the refs I see:

heads/master

remotes/origin/HEAD

remotes/origin/master

So why don't I see a remote head after the initial push?

NB. I've done the same via Git Bash command (ie. not Tortoise Git) and am seeing the same thing.


It's because HEAD is not a remote reference that you should push too, it's just a reference to the commit that HEAD of the remote repository points to. This repository on the server obviously has a working tree and is not created with a git init --bare command. I'm guessing Tortoise Git simply ignores it because some rules in the software. It sounds weird that git would fail to display it.


It's because you don't pull your repository. When you push you update the ref remote/origin/master, but not HEAD because it can be to other commit. If you pull after the HEAD arrive.

It's coming with your clone after. Fetch all refs from remote like HEAD and master

0

精彩评论

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