简体   繁体   中英

origin/HEAD points to wrong branch

still getting used to git, using source tree as the Git client.

I have a Git repo that has the master branch checked out.

I had two clones of this repo.

Today origin/Head magically appeared in one of them.

So I cloned the repo again to see if origin/HEAD would appear again, it did.

In the new repo origin/HEAD points to origin/master, as I would expect.

In the original repo origin/HEAD points to a different branch. ie origin/my_branch.

What could have happened to make origin/HEAD appear? From what I have read origin/HEAD should point to the checked out branch in the origin, why would it be pointing to a different branch?

How can I make origin/HEAD point to where I think it should be pointing? Can I remove origin/HEAD without making changes to the origin? should I not care and ignore this inconsisitence?

have I got this all totally wrong?

Thanks!

As mentioned in git remote set-head , origin/HEAD is the default branch (ie the target of the symbolic-ref refs/remotes/<name>/HEAD ) for the named remote.

You can remove it without changing the remote repo itself, since it is a local reference to your remote default branch.

See " How does origin/HEAD get set? ".

It can be set/updated with a git remote set-head origin -a , which is what you need to do to update it in your first repo.
It is set automatically on a git clone .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM