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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:22:06+00:00 2026-06-14T02:22:06+00:00

I have a bad commit from a long time ago, I want to remove

  • 0

I have a bad commit from a long time ago, I want to remove it completely from git history as if it never happened. I know the commit id let’s say 1f020. I have tried git rebase and remove it , but there is so many conflicts when rebasing that it is not possible that way. That commit is a simple 1 line change of code and pushing some files not related to the project.
So I want to write that 1 line code change and commit it, then replace somehow replace this new commit with the one a long time ago.

  • 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-14T02:22:08+00:00Added an answer on June 14, 2026 at 2:22 am

    If the offending commit is in a private repository, what you want to do is not a big deal. Rewriting published git history is irritating for your collaborators, so be sure removing this line is worth the cost.

    The git-rebase documentation has a helpful passage.

    git rebase [...] [<--onto newbase>] [<upstream>] [<branch>]
    

    A range of commits could also be removed with rebase. If we have the following situation:

    E---F---G---H---I---J  topicA
    

    then the command

    git rebase --onto topicA~5 topicA~3 topicA
    

    would result in the removal of commits F and G:

    E---H'---I'---J'  topicA
    

    This is useful if F and G were flawed in some way, or should not be part of topicA. Note that the argument to --onto and the upstream parameter can be any valid commit-ish.

    Assuming your history is linear and the offending commit is in your master branch, you can adapt the example above by running

    git rebase --onto 1f020~ 1f020 master
    

    For hairier situations, use interactive rebase. You may find it helpful to follow along with an example that merges two commits, but instead of marking the commit with s for squash, remove the entire line to remove the commit from your history.

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

Sidebar

Related Questions

I read everywhere that rewriting history of commits that have been published is bad
i hat one task, and know i have to continue but have a bad
I need help getting git extensions to run with msysgit. I have had bad
I have the string: i am a bad boy. I want to convert that
Currently we have no SVN/Git/Mercurial setup at work. We're fully aware it's a bad
Let's say I have committed some bad changes to Subversion repository. Then I commit
Unfortunately I have a pretty bad understanding of how to properly set up threading.
I become use raw socket and i have this problem: bad file descriptor the
I have clients with really bad networks, including bad mappings at the gateways and
Is it bad practice to have a custom cursor on a website? Not just

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.