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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:55:19+00:00 2026-06-16T07:55:19+00:00

I committed my changes, and started working on a new feature. I realized that

  • 0
  1. I committed my changes, and started working on a new feature.
  2. I realized that I have messed things up
  3. Needed to revert back to the previous commit.

What I did.

git add .
git commit -m "Screwed Up"
git branch -m experiment
git checkout 62b5 (SHA1 of previous commit)
git checkout -b master
git branch -D experiment

I think there must be a better way to revert to the previous commit.

When I tried, git reset HEAD, it would still show the uncommitted changes, when I do git status.

If there’s a better way to do it, what is it ? Or should I be using a different workflow to avoid situations like this ?

  • 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-06-16T07:55:20+00:00Added an answer on June 16, 2026 at 7:55 am

    You can do git reset --hard to revert back to the previous commit.

    --hard will reset the index and working tree. Any changes to tracked files in the working tree since the latest commit will be discarded.

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

Sidebar

Related Questions

I have solved some merge conflicts, committed then tried to Push my changes and
I've just started to work in a new place, and I see several things
I accidentally committed some changes to the repository that were not complete. I do
I have committed changes to Git and pushed to origin. Another developer was having
Suppose I have my master branch checked out. I've committed some production changes to
I have a weird problem that only started recently. When I run the app
I have started making some changes recently to my master branch to add featureX.
I committed a bunch of changesets locally (23-28) and then I realized that I
I inherited a project stored in CVS. The previous developer has massive un-committed changes
I initialized a Mercurial project on Machine A , committed my changes and uploaded

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.