Ever suffer from a detached head in Xcode?

Xcode is a joy and a curse. And the git integration sometimes goes wonky. About every month I get a detached head. Here’s a great fix that I’ll add one more small teak to..

  • Step 1. Create a branch called “temp” by typing: git branch temp
  • Step 2. Switch over to your new branch by checking it out: git checkout temp
  • Step 3. Point the master pointer to the temp branch pointer (the-f means force): git branch -f master temp . //here ‘master’ would be any branch that has a head that you want to realign
  • Step 4. Check out master (or whatever the problem branch was)
  • Step 5. Now we delete our temp branch: git branch -d temp
  • Step 6. Push our new changes to the remote repository: git push origin master //or whatever the problematic branch was