GIT: How to fix detached Head

Git like a swiss army knife : when you have problem with detached head on current develop repository which spin your head around. to solve this problem quite simple and easy:


  • Step 1. Create a branch called “tb” by typing:
    • $git branch tb
  • Step 2. check out tb branch:
    • $git checkout tb
  • Step 3. Force point master pointer to the new branch :
    • $git branch -f master tb
  • Step 4. Jum to master
    • $git checkout master
  • Step 5. Now we delete our tb branch:
    • $git branch -d tb
  • Step 5. Push our new changes to the remote repository:
    • git push origin master

Leave a Reply