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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:36:03+00:00 2026-05-25T03:36:03+00:00

My commit is already push to Github, let say A > B > C

  • 0

My commit is already push to Github, let say

A > B > C > D > E — HEAD

I want to revert back to B , so I use

git reset --hard <B:Hash>

Now, it will look like

A > B — HEAD

So, if I push it to the server with git push --force, I lost C,D,E in repository

How can I revert the file and commit to be the last revision like
A > B > C > D > E > F

F = Reverted: B

I cannot use git commit because it said there are no file to commit.

  • 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-25T03:36:04+00:00Added an answer on May 25, 2026 at 3:36 am

    Try this:

    git checkout B
    git reset --soft E
    git commit -m 'Reverted to B'
    

    The checkout command will change the working tree and index to match commit B. Reset with --soft will change the commit the current branch points to, without affecting the working tree or index. In other words, after the reset command, the index will be in exactly the same state as the B commit.


    You could also use git revert B..E, which will do the same thing, except it will create one new commit for each commit reverted. If you want the revert to happen in one commit, just add the -n option (git revert -n B..E) and Git will apply the reversion to the working directory and index. commit the result to finish the reversion.

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

Sidebar

Related Questions

I do: $ git commit . $ git push error: Entry 'file.php' not uptodate.
My friend and I have elected to use git and GitHub to collaborate on
I have a repository already online, but I want to commit what I have
I commit all my files into bitbucket. i try check in,revert file i deleted
I want to commit a large amount of XML files which have been modified.
Some Git commands take commit ranges and one valid syntax is to separate two
I want to automatically commit the database when we copy files from one branch
I accidentally pushed a commit to GitHub. Is it possible to remove this commit?
Suppose I have 5 local commits. I want to push only 2 of them
I want to have a bare git repository stored on a (windows) network share.

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.