Search code examples
gitgithubtortoisegit

Staying on no branch after pulling and switching to a branch


I'm trying to switch another branch but I keep staying on a detached head or no branch.

What I tried:

Switch/Checkout:

enter image description here

Getting:

enter image description here

But if I want to commit, I'm still on no branch:

enter image description here

And if I try to pull this branch instead:

enter image description here

I'm getting:

enter image description here

And I'm still on no branch...

How can I actually go back to the portalGraphs branch?


Solution

  • You tried to directly checkout a remote tracked branch. In the git philosophy this is not possible and git checks out a so-called "detached HEAD", i.e., you are not an a branch but the revision will be your HEAD (cf. Why does Git tell me "Not currently on any branch" after I run "git checkout origin/<branch>"?).

    When you opened the switch/checkout dialog and you selected the remote branch, the "Create new branch" checkbox was automatically selected. This would create a local branch on the version of the remote branch. See

    A quick way to fix this is to go to the switch/checkout dialog and select a local branch, such as master OR select "new branch" on the commit dialog.