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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:33:51+00:00 2026-06-19T03:33:51+00:00

I have a git repository in which I have made quite a few changes,

  • 0

I have a git repository in which I have made quite a few changes, and pushed to a remote location.

I wish to reset the repository to the 3 commit from the first, push it to the remote branch. I’m considering doing the following :-

  • git reset
  • git push origin master

A couple of doubts regarding the same?

  • Would this be the right way to do it?
  • I have deleted certain files and added a few files after the 3rd commit(from the first). I wish to change all that back to the state of the 3rd commit(get back the deleted files, remove the newly added ones). How could I go about doing that?

Thanks.

[EDIT]
I’m a solo developer on this project at this point in time. Also there are quite a few commits made so Id rather not manually have to revert each one of them.

  • 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-19T03:33:52+00:00Added an answer on June 19, 2026 at 3:33 am

    As you already sent your files to a remote repository, it is not a good idea to perform a git reset because other developers should updated their local repositories and get the new updates. The best solution is to perform a git revert, a command that generates a new commit that undo what a previous commit did. For more information, take a look at this link.

    But if you were the only developer of this project, you can delete the commits. For this, you can use the git reset command:

    git reset --hard hash
    

    where hash is the commit hash that you want to return. The option --hard is to almost complete remove the commits after the commit hash you passed.

    As you were changing the project history, you can’t perform a simple push. You will need the flag -f to force the update:

    git push -f origin master
    

    However, some remote repositories have some hook that prohibits you to force update the history. You will need to delete this hook to allow you to perform a history update. If you can’t do this, you will need to use the git revert command.

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

Sidebar

Related Questions

We have a git repository which contains source for a few related Java WARs
In our Git repository we have a few merges from branches that should have
I have a local git repository which tracks a remote SVN repository via git
I have a Git repository which I have started to develop on master branch
I have just one cs file in my repository which Git seems to think
I have committed a few source files to my git repository and tagged it
I had a mistake and commit some changes to git which I should not
I have an SVN repository which was renamed from Project to Project v1. I
I have a central git repository which myself and several collaborators regularly push and
I have a project I forked on github to my repository. I made changes

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.