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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:10:02+00:00 2026-05-14T00:10:02+00:00

I created a local Git repo on my laptop and then pushed the source

  • 0

I created a local Git repo on my laptop and then pushed the source to Heroku creating a remote branch. After a few days of commits and pushes, I need to rollback to an earlier commit. Here’s what I did.

cd <app root>
git checkout 35fbd894eef3e114c814cc3c7ac7bb50b28f6b73 

Someone told me that doing the checkout created a new working tree and not the branch itself, so when I pushed the rollback changes to Heroku, it said everything is up to date and nothing was pushed. How do I fix this situation? Thanks for your help in advance.

  • 1 1 Answer
  • 2 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-14T00:10:03+00:00Added an answer on May 14, 2026 at 12:10 am

    When you checkout a direct commit name (using the SHA-1 hash of the commit object) instead of checking out a branch name, you end up with a “detached HEAD”. HEAD is the “ref” that keeps track of what is currently checked out. It becomes detached when you directly checkout a commit instead of a branch (it is not attached to any branch). No branches are updated when you detach a repository’s HEAD. You might think of the detached head state as if you had an anonymous branch checked out.


    To reattach your repository’s HEAD, you will want to save the current HEAD as a branch and check that branch out:

    1. To save the current HEAD in a new branch do this:

      git branch <new-branch-name>
      
    2. To overwrite an existing branch you need to use --force:

      git branch --force <existing-branch-name>
      
    3. Then, reattach your repository’s HEAD by checking out the new/updated branch:

      git checkout <branch-name>
      

      (where <branch-name> is the same as <new-branch-name> or <existing-branch-name>, depending on which of the above two commands you used)

    This sequence (git branch to make a ref point to the current HEAD commit, then git checkout that updated branch) will carry forward any uncommitted content that you might have in your working index and/or tree.


    In the future, if you want to ‘roll back’ the current branch to some previous commit, you should use this instead of detaching your repository’s HEAD:

    git reset --hard <commit>
    

    This will reset the current branch (or your detached HEAD, if it is already detached) to the named commit, and make the index and the working tree reflect that commit (i.e. it throws away any commits since the specified commit along with any uncommitted content).

    The detached HEAD state is useful for revisiting old states, and sometimes for short-term work that you are not sure you will keep. Other than that you probably want to avoid it.

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

Sidebar

Related Questions

So I've created a repo using Git Bash, and it works (Local and Remote
I have a local git repo created by Qt Creator during the New Project
I have a local Git repository I've been developing under for a few days:
I cannot find any of the files on my remote repo. Created a Git
I have a remote repository and a local repo. I did a git fetch
I created a branch on my local Mercurial repository. I want to push to
I have a local branch work, where I created two new files a.py, b.py
Possible Duplicate: git push error '[remote rejected] master -> master (branch is currently checked
I created a shared repo by: git init --bare my_project.git At some point, another
I have a branch called develop in remote bare repo hub , and I

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.