Skip to content

Latest commit

 

History

History
21 lines (16 loc) · 722 Bytes

fix-detached-head-submodule.md

File metadata and controls

21 lines (16 loc) · 722 Bytes

Fixing Detached HEAD in a Git Submodule

When working with Git submodules, you might encounter a situation where the submodule is in a detached HEAD state. This can be problematic if you need to make changes and commit them. Here’s how you can fix it:

Steps to Fix Detached HEAD

  1. Navigate to the Submodule Directory

    cd path/to/your/submodule
  2. Check the Current Status

    # if the master branch already exists locally:
    git branch -u <origin>/<branch> <branch>
    # else:
    git checkout -b <branch> --track <origin>/<branch>

source

I am a helpful link