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 441747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:00:11+00:00 2026-05-12T21:00:11+00:00

Okay so I made some changes in my project that resulted in a huge

  • 0

Okay so I made some changes in my project that resulted in a huge mess. I had already committed the changes so I could go back to it later, and then used git checkout HEAD^ to checkout the previous commit. Now as I’m making commits to my project it shows the SHA-1 on the command line as the working branch (instead of master)

I don’t know everything there is to know about git but I’m guessing HEAD is still pointing to my broken copy as I’m going off in a tangent and have resolved the problem. How can I point HEAD to the latest commit I’m working from?

I’m guessing it has to do with rebase but I’m not 100% sure.

Thanks.

  • 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-12T21:00:12+00:00Added an answer on May 12, 2026 at 9:00 pm

    Now as I’m making commits to my project it shows the SHA-1 on the command line as the working branch (instead of master)

    This probably means you have a “detached HEAD”. A detached HEAD points directly to a commit instead of pointing to a branch (which then points to a commit). A detached head is like an unnamed branch.

    This state was caused by your git checkout HEAD^ command as HEAD^ refers to a commit, not to a branch name. You probably wanted to do git reset --hard HEAD^—while master was still the active branch—to drop the most recent commit from master (it would still exist on disk and be reachable through the reflog until its entry in the reflog expired).

    How can I point HEAD to the latest commit I’m working from?

    HEAD is always the commit from which you are working, whether it is detached or not.

    If you mean “How can I point master to the latest commit I’m working from?”, then that is the same as asking “How can I get master to point to HEAD?”. The answer is

    git branch -f master HEAD
    

    (actually, you can leave off HEAD, since it is the default). This forcibly resets master to the commit currently at HEAD. Any commits on master that are not reachable via another branch or the current HEAD will henceforth only be reachable via the reflog and will eventually be garbage collected (this throws away, from master, anything in master that is not in HEAD). You also probably want to reattach your HEAD to this updated master after this.

    git checkout master
    

    Instead of the two commands above, you could reattach HEAD first, then reset master with these two consecutive commands:

    git checkout master         # reattach, commit at HEAD is now the unwanted commit
    git reset --hard HEAD@{1}   # reset master to the commit at HEAD before the prior command
    

    The HEAD@{1} notation is used to access entries in the reflog. This example just means “the previous HEAD” (i.e. “the commit at HEAD before the most recent operation that affected HEAD”).

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

Sidebar

Related Questions

Okay so I made some changes to a stored procedure that we have, and
Okay, this is pretty weird. I made an app that listens for changes inside
I finished my little project that does some heavy lifting. i realized in this
Okay, I kinda asked this question already, but noticed that i might have not
What's happening Okay, so I've made a function on my front page where some
I am working on a php+javascript based project and have already made up a
I have made this code that makes some visual tiles that fades in and
Okay, just learnt LINQ syntax about ten minutes ago, made a first program: public
Okay, next PHPExcel question. I have an HTML form that users fill out and
okay, i'm setting up a multi-user chat system. i have a messages table, that

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.