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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:15:25+00:00 2026-05-24T12:15:25+00:00

I am using GitHub as my remote repository. I have already pushed 5 commits

  • 0

I am using GitHub as my remote repository.

I have already pushed 5 commits to the server and want to revert back to the state before the those commits.

If the commit hash is 3425661dba2aadccdbab, how do I revert the entire local/remote back to that commit? I tried

$ reset --hard 3425661dba2aadccdbab

but that only resetted my working head to that branch and requires me to do a git pull again. I tried checkout, but this caused me to land in a “detached head” branch.

  • 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-24T12:15:26+00:00Added an answer on May 24, 2026 at 12:15 pm

    You basically have two options to revert changes:

    1. create a new commit which applies reverse changes. This is the preferred option as it doesn’t changes history on a public repository
    2. Remove the commits and force push them.

    The first option can be achieved by using git revert

    git-revert – Revert some existing commits

    Given one or more existing commits, revert the changes that the related patches introduce, and record some new commits that record them.

    An example would be git revert -n HEAD~5..HEAD. This command creates 5 new commits, each of which undoes one of the last 5 commits of the currently checked out branch.

    The second option would be to actually remove the commits. Note that this changes history in the repository. So anyone who has already pull the changes will probably be rather surprised and things can get messy quickly. That said, you can do

    git reset --hard HEAD~5
    git push --force
    

    The first command will wipe any uncommitted changes in your current working copy. and reset your local repository to the state of the current HEAD – 5 commits. The second command will force-push to the default remote (i.e. GitHub) There, any changes diverging from your current local repository are overwritten.

    A note of warning again: If you don’t really know what you are doing, don’t use this option as it can lead to data loss for you or others if not done right. Use the first option instead as it will transparently remove changes but without the nasty side-effects of history-rewriting.

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

Sidebar

Related Questions

I am using a git repository with github. With all the commits and logs
I am not using github. We have git setup on our machine. I created
I'm currently using a github repository with a single branch, based of a master
I have been using git and github with my small team of developers for
I'm using one file from a git repository off of github in a project
(Using Vista)I'm trying to clone an app from my GitHub Repository and push it
I have been using https://github.com/Redth/APNS-Sharp to send push notification message to all devices where
I'm trying to fetch a read-only git repository from github and have it be
I'm using github to store the repository, and I'm reading Deploy with Capistrano :
I've used to using Github as a backup or a central repository and doing

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.