2

I'm new to programming so please dont bite my head off! I'm using Xcode with GitHub, but it's suddenly stopped working. Xcode is not showing the current branch on source control, it doesnt load remote repositories, and the git status is 'head detached'.

I've gone to the command line and done 'sudo git --version', and accepted the new license.

This project is for fun, but I've put a lot of work into it. I don't mind just losing the history of the project if need be, I'd just like to get GitHub's source control back to a working state. Any suggestions?

enter image description here

L Y E S - C H I O U K H
  • 4,765
  • 8
  • 40
  • 57
  • Possible duplicate of [Fix a Git detached head?](https://stackoverflow.com/questions/10228760/fix-a-git-detached-head) – webFashion Mar 20 '18 at 15:18

2 Answers2

2

If you want to add commit with detached head to any branch you should use cherry-pick command

git checkout "branchname"
git cherry-pick "commitnumber"
belebeich
  • 391
  • 3
  • 8
0

Your screenshot is showing that you checked out a specific commit. The long hexadecimal number partially obscured by the red line in the screenshot is the commit number. When you check out a specific commit, you don't have a current branch so the git head is detached.

The fix is to check out a branch so you have a current branch again. Select a branch inside the Branches folder, the BrianTests branch in your screenshot, right-click, and choose Checkout.

Swift Dev Journal
  • 19,282
  • 4
  • 56
  • 66