Skip to content

Instantly share code, notes, and snippets.

@marcusholloway17
Last active October 4, 2023 20:09
Show Gist options
  • Select an option

  • Save marcusholloway17/e4f230b5414fec482900a311acd6d74f to your computer and use it in GitHub Desktop.

Select an option

Save marcusholloway17/e4f230b5414fec482900a311acd6d74f to your computer and use it in GitHub Desktop.
HOW TO FIX FIX DETACHED HEAD ERROR

HOW TO FIX FIX DETACHED HEAD ERROR

When working in Live Development mode, attempting to push your changes using git push can occasionally fail with a message similar to the following:

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

This detached head state occurs when a specific commit is checked out instead of a branch. You cannot commit to a commit—only to a branch. To correct this, use the following steps to create a branch for your commits:

1- From a command prompt window, create a branch by using a command similar to the following:

git checkout -b [branchname]

2- Commit your changes to the branch.

3- Push the branch that you created into the origin Git repository:

git push origin [branchname]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment