Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 21
    This is almost a great answer, but fails to explain why you got into a detached head state.
    – Goose
    Commented May 12, 2016 at 18:25
  • 11
    I agree but it does provide the solution i was looking for. Thanks!!
    – Kilmazing
    Commented Mar 15, 2017 at 15:07
  • I saw in this other answer that git checkout -b Feature/f1234 <=> git branch Feature/f1234 and git checkout Feature/f1234.
    – Armfoot
    Commented Jul 13, 2017 at 18:25
  • 2
    by default it looks in origin, so when you give origin/branchname, it looks for origin/origin/branchname to tell that first one is remote name you use -b, if u don't it creates a anonymous branch which is detached. Similarly for checking out from a different remote you would have to mention -b parameter otherwise git doesn't have a way to know it is from a new remote, it will look for origin/remote/branchname.
    – garg10may
    Commented Aug 14, 2017 at 7:02
  • 2
    The hint about omitting "origin/" worked like a charm. Thanks!
    – SMBiggs
    Commented Oct 28, 2020 at 19:57