Fix a Git detached head?

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

    If you have changed files you don't want to lose, you can push them. I have committed them in the detached mode and after that you can move to a temporary branch to integrate later in master.

    git commit -m "....."
    git branch my-temporary-work
    git checkout master
    git merge my-temporary-work
    

    Extracted from:

    What to do with commit made in a detached head

提交回复
热议问题