Fix a Git detached head?

前端 未结 23 1678
臣服心动
臣服心动 2020-11-22 05:42

I was doing some work in my repository and noticed a file had local changes. I didn\'t want them anymore so I deleted the file, thinking I can just checkout a fresh copy. I

23条回答
  •  执笔经年
    2020-11-22 06:39

    Being in "detached head" means that HEAD refers to a specific unnamed commit (as opposite to a named branch) (cf: https://git-scm.com/docs/git-checkout section Detached head)

    To fix the problem, you only need to select the branch that was selected before by

    git checkout @{-1}

提交回复
热议问题