Skip to content

warn user when trying to commit with detached HEAD #788

Open

Description

@shiftkey

In case the user is in the detached HEAD scenario, we should warn the user in case they try to commit, and help them get back to a safe state.

xref #786 (comment)

Activity

  1. donokuda commented on Jan 11, 2017

    @donokuda
    Contributor

    Detached HEAD always sounds so gruesome 💀

    When I checkout into a detached HEAD state, Git gives me a heads up about where I'm ending up and what I can do:

    Note: checking out '7ada1c16d50d746e56612085'.
    
    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.
    
    If you want to create a new branch to retain commits you create, you may
    do so (now or later) by using -b with the checkout command again. Example:
    
      git checkout -b <new-branch-name>
    
    HEAD is now at 7ada1c1... Change 2
    

    I'm thinking that it's okay for users to go ahead and make commits without warning them. The moment we should consider warning the user is when they try to switch out of the detached HEAD state (via switching to a branch.) We could let them know that they will potentially lose X number of commits and prompt them to create a branch to save their changes (or discard if they don't.)

  2. shiftkey commented on Mar 22, 2018

    @shiftkey
    MemberAuthor

    Bumping this because the current UI still shows master as the branch you're going to commit to

  3. added
    not-planned
    on Jul 8, 2024
  4. added a commit that references this issue on Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementnot-planned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions