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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:40:13+00:00 2026-06-13T08:40:13+00:00

Here is what I’ve done: Create folder testA Create a file a.txt with it’s

  • 0

Here is what I’ve done:

  • Create folder testA
  • Create a file “a.txt” with it’s contents “a”
  • Git init into the folder testA
  • git add .
  • git commit -a -m “first”
  • change the file’s “a.txt” contents to “b”
  • git add .
  • git commit -a -m “changed to b”
  • git log (to get the commit id of the “first” )
  • git revert a90deafe08c9f8f0d7b94d3d74d40be2bd65b161

I get in console:

error: could not revert a90deaf... first
hint: after resolving the conflicts, mark the
hint: with 'git add <paths>' or 'git rm <paths
hint: and commit the result with 'git commit'

Well, I would like to have all the files at the state of the previous commit, what should I do know?

UPDATE
What I would want:

  • I would like to keep the “changed to b” commit and have a third one that is exactly the same as the “first” commit. I never ever want to lose any file.
  • To work with binary files (see next point)
  • I don’t care how binary files are manage as long as I can have them in the state of the commit, so merge is not necessary in this case. I just want something easier: replace file A from commit X to commit Y, no complications with merge needed.
  • 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-13T08:40:14+00:00Added an answer on June 13, 2026 at 8:40 am

    First, get back to a good state with:

    git revert --abort
    

    Next, look at what you’re asking. git revert takes the commit id of the commit you want to undo. The first commit sets a.txt to be:

    a
    

    The second commit makes it have:

    b
    

    And you want to revert the first commit. So what that is saying is that you’d like to remove the addition of the a line, and the addition of the file which is a conflict. The first commit added the file, and the second commit modified it. So git doesn’t know what to do now that you’re asking to remove it.

    I assume by “all the files at the state of the previous commit” that you want to get back to the state where a.txt has a in it.

    There are a couple of ways to get back to the previous state. If the commits have not been shared, you can simply use git reset:

    git reset --hard HEAD~1
    

    This says “reset the state of my working copy and index to the previous commit”. At this point, a.txt will have a in it.

    If you had shared the second commit, then you don’t want to do the above, because you’ll be rewriting history, which causes a whole host of other issues. Instead, revert the commit, like you were trying to do above, but use the right commit. In this case, it’s the HEAD commit you want to revert:

    git revert HEAD
    

    There are times when reverting a commit may conflict. In that case, it’s very much like merge conflicts. You need to work through them, fixing up the conflicts and either using git add to stage the file with the modifications, or using git rm to remove the file. Once you’re done, git revert --continue will let the process finish.

    Update

    The easiest way to go to restore the previous state, without having to do any fancy merging, is to use git checkout. You can do:

    git checkout HEAD~1 -- a.txt
    git commit -m "Reverted to the previous version."
    

    No merging, no fuss. 🙂 HEAD~1 can be any commit, of course. I just used this based on the example you had.

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

Sidebar

Related Questions

Here is my problem.. I have the option to create(add) two new input fields,
Here is the code: create table `team`.`User`( `UserID` bigint NOT NULL AUTO_INCREMENT , `Username`
Here is my SQL script CREATE TABLE tracks( track_id int NOT NULL AUTO_INCREMENT, account_id
Here's an example query: DECLARE @table table (loc varchar(10)) INSERT INTO @table VALUES ('134a'),
Here's what I'm doing. I want to upload multipart file via Ajax to my
Here's my procedure: DROP PROCEDURE IF EXISTS `couponExpires`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `couponExpires`(IN couponID BIGINT,
Here is my problem : I have a post controller with the action create.
Here is an example. foreach (var doc in documents) { var processor = this.factory.Create();
Here is my problem. Our tech. writer or customer service will often create new
Here's the code I have. It works. The only problem is that the first

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.