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

  • Home
  • SEARCH
  • 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 7578851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:31:43+00:00 2026-05-30T17:31:43+00:00

I know that Git tracks changes I make to my application, and holds on

  • 0

I know that Git tracks changes I make to my application, and holds on to them until I commit the changes.

To revert to a previous commit, I used:

$ git reset --hard HEAD

HEAD is now at 820f417 micro

How do I then revert the files on my hard drive back to that previous commit?

My next steps were:

git add .
git commit -m "revert"

But none of the files have changed on my hard drive…

  • 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-30T17:31:44+00:00Added an answer on May 30, 2026 at 5:31 pm

    First, it’s always worth noting that git reset --hard is a potentially dangerous command, since it throws away all your uncommitted changes. For safety, you should always check that the output of git status is clean (that is, empty) before using it.

    Initially you say the following:

    So I know that Git tracks changes I make to my application, and it holds on to them until I commit the changes, but here’s where I’m hung up:

    That’s incorrect. Git only records the state of the files when you stage them (with git add) or when you create a commit. Once you’ve created a commit which has your project files in a particular state, they’re very safe, but until then Git’s not really “tracking changes” to your files. (for example, even if you do git add to stage a new version of the file, that overwrites the previously staged version of that file in the staging area.)

    In your question you then go on to ask the following:

    When I want to revert to a previous commit I use: git reset –hard HEAD And git returns: HEAD is now at 820f417 micro

    How do I then revert the files on my hard drive back to that previous commit?

    If you do git reset --hard <SOME-COMMIT> then Git will:

    • Make your current branch (typically master) back to point at <SOME-COMMIT>.
    • Then make the files in your working tree and the index (“staging area”) the same as the versions committed in <SOME-COMMIT>.

    HEAD points to your current branch (or current commit), so all that git reset --hard HEAD will do is to throw away any uncommitted changes you have.

    So, suppose the good commit that you want to go back to is f414f31. (You can find that via git log or any history browser.) You then have a few different options depending on exactly what you want to do:

    • Change your current branch to point to the older commit instead. You could do that with git reset --hard f414f31. However, this is rewriting the history of your branch, so you should avoid it if you’ve shared this branch with anyone. Also, the commits you did after f414f31 will no longer be in the history of your master branch.
    • Create a new commit that represents exactly the same state of the project as f414f31, but just adds that on to the history, so you don’t lose any history. You can do that using the steps suggested in this answer – something like:

      git reset --hard f414f31
      git reset --soft HEAD@{1}
      git commit -m "Reverting to the state of the project at f414f31"
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that GIT rebases will rewrite the history -- i.e. the commit ids
I know that I can use the git diff command to check the changes,
I know how to make a new branch that tracks remote branches, but how
Assuming that I know there is a git-daemon running at git://git.mycompany.com , how can
I know that |DataDirectory| will resolve to App_Data in an ASP.NET application but is
I know that I have git add -p to manually choose what chunks to
I know that git diff --word-diff=color shows a word diff between the working tree
As I am learning Git, I get to know that the other VCS systems
I know that git provides the 'git rm' and 'git mv' to remove/move files
Do you know that is there any repo(git, or something else) of the GAE

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.