简体   繁体   中英

Git, HEAD points to a wrong branch

There is the output of git branch -av command. Now I am on the dev branch.

***dev** 3f126e0 Comment...
master 7a47db8 Another comment...
remotes/origin/HEAD   -> origin/master
remotes/origin/dev 3f126e0 Comment...
remotes/origin/master 7a47db8 Another comment...

From the book Pro Git by Scott Checkon.

How does Git know what branch you're currently on? It keeps a special pointer called HEAD.

Why does HEAD point to origin/master while I am on dev ?

HEAD isn't pointing at origin/master ; remotes/origin/HEAD is pointing at origin/master .

See what HEAD is pointing at with git symbolic-ref HEAD .

It just tells you that master is the default branch of your remote repository. But yeah anyway Head is normaly the checked out branch, but in this sittuation it just provides the default branch info. Its not that importend anyway. A case would be if you clone a repo the default branch gets used.

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