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

Ask A Question

Stats

  • Questions 260k
  • Answers 260k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer By passing the contents using file_get_contents() and such you have… May 13, 2026 at 11:21 am
  • Editorial Team
    Editorial Team added an answer Use the two-argument form of URLClassLoader.newInstance to set the parent… May 13, 2026 at 11:21 am
  • Editorial Team
    Editorial Team added an answer Not aware of any standard, but I'm sure that the… May 13, 2026 at 11:21 am

Related Questions

I'm using subversion so that I can have two checkouts, one for testing to
I have an application that has multiple states, with each state responding to input
Okay big brains here's something that's more of a challenge than a requirement. I
Okay, a little preface: I am still a beginner when it comes to AJAX,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.