HEAD detached from XXXX solution

On the way to commit git, there is a problem

1. Appears after git push origin master

Everything up-to-date

At that time, I thought the question was wrong, and I resubmitted it again. After the git commit, the error HEAD detached from 4d1722c appeared.

Immediately use git status to check, which is also the same. At that time, the online tutorial was very unclear, and I also git checkout master myself, which caused the code to be almost lost.

2. The specific method is as follows

  • git reflog Find the commit that needs to be restored and write down the previous commit id
  • git branch temp efa64f5 Create a new branch named temp, use this branch to replace the previous temporary branch and have the commit you want to restore, efa64f5 is the commit id to restore
  • git push origin temp push to the warehouse
  • git checkout master switches to the master branch
  • git merge temp merge temp to master
  • To be on the safe side, first push git push origin master to the warehouse
  • Check if it is updated, if it is updated, git branch -d temp deletes the branch

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324600335&siteId=291194637