https://stackoverflow.com/questions/5772192/how-can-i-reconcile-detached-head-with-master-origin
First, let’s clarify what HEAD is and what it means when it is detached. HEAD is the symbolic name for the currently checked out commit. When HEAD is not detached (the “normal”1 situation: you have a branch checked out), HEAD actually points to a branch’s “ref” and the branch points to the commit. HEAD is thus “attached” to a branch. When you make a new commit, the branch that HEAD points to is updated to point to the new commit. HEAD follows automatically since it just points to the branch.
the above pretty much means that you did not create a local branch before checking out a remote one
go back to the branch you had checked out before
git checkout master
fetch all remote branches
git fetch
get a list of all the remote branches
git branch -r
git switch -c new-branch-name origin/new-branch-name
your suppose to be able to just fetch and then checkout. But if your configuration file is not setup correctly, by default, master will be the only branch fetched. to fetch all branches reference the link below
https://stackoverflow.com/questions/11623862/fetch-in-git-doesnt-get-all-branches