Fix a Git detached head?

前端 未结 23 1374
臣服心动
臣服心动 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:37

    The detached HEAD means that you are currently not on any branch. If you want to KEEP your current changes and simply create a new branch, this is what you do:

    git commit -m "your commit message"
    git checkout -b new_branch
    

    Afterwards, you potentially want to merge this new branch with other branches. Always helpful is the git "a dog" command:

    git log --all --decorate --oneline --graph
    

提交回复
热议问题