Skip to content

Instantly share code, notes, and snippets.

@andmax
Created November 10, 2020 16:13
Show Gist options
  • Save andmax/2ef51dbb2475489564206c8560aeeb45 to your computer and use it in GitHub Desktop.
Save andmax/2ef51dbb2475489564206c8560aeeb45 to your computer and use it in GitHub Desktop.
Teaches a simple fix when git HEAD is detached
1. Sometimes a git submodule may lose its head during commit
2. It appears as: HEAD detached ...
3. This may be because the commit done as submodule creates
4. a "virtual" branch (hopefully will be fixed in the future)
5. One way to fix it is to do:
cd <submodule dir>
git add <changed files in submodule>
git commit -m <message>
git status # showing HEAD detached
git branch tmp
git checkout master
git merge tmp
git branch -d tmp
git push origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment