![]() ![]() The main reason is that if you make a new commit from that tag then given that that commit is not referenced by anything (not any branch or tag) then still its considered a detached HEAD.Īttached HEADs can only happen when you're on a branch. If you checkout a tag, then you're again on a detached HEAD. Tags on the other hand are not meant to be like that. It will update its HEAD as you make commits. To go a bit deeper a branch is built in a way that it's smart. ![]() May do so (now or later) by using -b with the checkout command again. If you want to create a new branch to retain commits you create, you As a result below that message it also says: Hence it's informing your HEAD is not associated to a branch so you're more inclined to checkout a new branch. Then if you made some changes and made a commit, you're still NOT on a branch.ĭo you think you'd remember the commit SHA? You won't! So suppose you checked out a commit (not a branch) i.e. Because you have thousands of commits but only very few branches.Ī detached commit’s identifier is just its SHA. But to do the same with just commits you'd have to do git reflog which is very tedious. And we can just do git branch and get a list of all branches. main and new-button-feature are easy to remember. We do git checkout new-button-feature / git checkout main. We as people can easily remember branch names. If git was to rename detached HEAD I would have it named as a HEAD that isn’t identified by a branch and will soon be forgotten. If is not found but there does exist a tracking branch in exactly one remote (call it ) with a matching name, treat as equivalent to git switch -c -track /Īnd if you git switch instead of git switch -detach, Git 2.36 will help you to remember the missing -detach option. If you wanted to create a new local branch tracking a remote branch: git switch using the new git switch command: C:\Users\vonc\arepo>git switch origin/masterįatal: a branch is expected, got remote branch 'origin/master' See: C:\Users\vonc\arepo>git checkout origin/master
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |