Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4542486
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:23:51+00:00 2026-05-21T15:23:51+00:00

I’m new at the branching complexities of Git. I always work on a single

  • 0

I’m new at the branching complexities of Git. I always work on a single branch and commit changes and then periodically push to my remote origin.

Somewhere recently, I did a reset of some files to get them out of commit staging, and later did a rebase -i to get rid of a couple recent local commits. Now I’m in a state I don’t quite understand.

In my working area, git log shows exactly what I’d expect– I’m on the right train with the commits I didn’t want gone, and new ones there, etc.

But I just pushed to the remote repository, and what’s there is different– a couple of the commits I’d killed in the rebase got pushed, and the new ones committed locally aren’t there.

I think “master/origin” is detached from HEAD, but I’m not 100% clear on what that means, how to visualize it with the command line tools, and how to fix it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T15:23:52+00:00Added an answer on May 21, 2026 at 3:23 pm

    First, let’s clarify what HEAD is and what it means when it is detached.

    HEAD is the symbolic name for the currently checked out commit. When HEAD is not detached (the “normal”1 situation: you have a branch checked out), HEAD actually points to a branch’s “ref” and the branch points to the commit. HEAD is thus “attached” to a branch. When you make a new commit, the branch that HEAD points to is updated to point to the new commit. HEAD follows automatically since it just points to the branch.

    • git symbolic-ref HEAD yields refs/heads/master
      The branch named “master” is checked out.
    • git rev-parse refs/heads/master yield 17a02998078923f2d62811326d130de991d1a95a
      That commit is the current tip or “head” of the master branch.
    • git rev-parse HEAD also yields 17a02998078923f2d62811326d130de991d1a95a
      This is what it means to be a “symbolic ref”. It points to an object through some other reference.
      (Symbolic refs were originally implemented as symbolic links, but later changed to plain files with extra interpretation so that they could be used on platforms that do not have symlinks.)

    We have HEAD → refs/heads/master → 17a02998078923f2d62811326d130de991d1a95a

    When HEAD is detached, it points directly to a commit—instead of indirectly pointing to one through a branch. You can think of a detached HEAD as being on an unnamed branch.

    • git symbolic-ref HEAD fails with fatal: ref HEAD is not a symbolic ref
    • git rev-parse HEAD yields 17a02998078923f2d62811326d130de991d1a95a
      Since it is not a symbolic ref, it must point directly to the commit itself.

    We have HEAD → 17a02998078923f2d62811326d130de991d1a95a

    The important thing to remember with a detached HEAD is that if the commit it points to is otherwise unreferenced (no other ref can reach it), then it will become “dangling” when you checkout some other commit. Eventually, such dangling commits will be pruned through the garbage collection process (by default, they are kept for at least 2 weeks and may be kept longer by being referenced by HEAD’s reflog).

    1
    It is perfectly fine to do “normal” work with a detached HEAD, you just have to keep track of what you are doing to avoid having to fish dropped history out of the reflog.


    The intermediate steps of an interactive rebase are done with a detached HEAD (partially to avoid polluting the active branch’s reflog). If you finish the full rebase operation, it will update your original branch with the cumulative result of the rebase operation and reattach HEAD to the original branch. My guess is that you never fully completed the rebase process; this will leave you with a detached HEAD pointing to the commit that was most recently processed by the rebase operation.

    To recover from your situation, you should create a branch that points to the commit currently pointed to by your detached HEAD:

    git branch temp
    git checkout temp
    

    (these two commands can be abbreviated as git checkout -b temp)

    This will reattach your HEAD to the new temp branch.

    Next, you should compare the current commit (and its history) with the normal branch on which you expected to be working:

    git log --graph --decorate --pretty=oneline --abbrev-commit master origin/master temp
    git diff master temp
    git diff origin/master temp
    

    (You will probably want to experiment with the log options: add -p, leave off --pretty=… to see the whole log message, etc.)

    If your new temp branch looks good, you may want to update (e.g.) master to point to it:

    git branch -f master temp
    git checkout master
    

    (these two commands can be abbreviated as git checkout -B master temp)

    You can then delete the temporary branch:

    git branch -d temp
    

    Finally, you will probably want to push the reestablished history:

    git push origin master
    

    You may need to add --force to the end of this command to push if the remote branch can not be “fast-forwarded” to the new commit (i.e. you dropped, or rewrote some existing commit, or otherwise rewrote some bit of history).

    If you were in the middle of a rebase operation you should probably clean it up. You can check whether a rebase was in process by looking for the directory .git/rebase-merge/. You can manually clean up the in-progress rebase by just deleting that directory (e.g. if you no longer remember the purpose and context of the active rebase operation). Usually you would use git rebase --abort, but that does some extra resetting that you probably want to avoid (it moves HEAD back to the original branch and resets it back to the original commit, which will undo some of the work we did above).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I have a jquery bug and I've been looking for hours now, I can't
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.