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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:10:53+00:00 2026-06-09T20:10:53+00:00

Two commits ago, I accidently changed a free picture with a picture which is

  • 0

Two commits ago, I accidently changed a free picture with a picture which is protected by law (well I am not allowed to distribute that image). I haven’t pushed to github yet. How can I undo these changes made to the picture, so that it doesn’t show up in the commit history? As if this picture was never changed.

  • 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-09T20:10:54+00:00Added an answer on June 9, 2026 at 8:10 pm

    Use git rebase -i HEAD~2. When you’re prompted for what you want to do, for the commit you need to change, replace “pick” with “edit”. This will allow you to edit the commit you specify, and that means edit the entire commit, not just the message.

    (Or, if you don’t need that commit at all, just delete the line containing the bad commit. The rebase will finish and make it so that commit never happened. In that case, there’s no need to read the rest of this.)

    When you kick of the rebase (by saving and exiting whatever editor you’re using), you’ll get a prompt that reads something like the below:

    Stopeed at 98ad8ac... Add an image I really oughtn't add.
    You can amend the commit now, with
    
            git commit --amend
    
    Once you are satisfied with your changes, run
    
            git rebase --continue
    

    So do exactly that! Make the changes you need to make to the commit (ie delete the non-free image, put the free image back), then run git commit --amend. That’ll replace your bad commit with the new one.

    (Alternative: run git reset HEAD^ at this point. That’ll make it as if the commit didn’t happen, but all the changes from the commit will be in your working copy, so you can stage/back out/whatever changes as you need. Then run git commit as usual.)

    Then run git rebase --continue, and Git will apply your second commit on top of your first one, and your history will only contain the correct fix, not the duff one.

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

Sidebar

Related Questions

A riff on git: show all changed files between two commits : I want
I have a project with one directory that was originally (several hundred commits ago)
I have two commits that I just pushed to github The 2nd commit message
I'm trying to export a list of changed files from two commits with git,
Possible Duplicate: git: show all changed files between two commits How can I get
In case of a submodule conflict (i.e. when the two commits to merge contain
I have two branches with several commits each. On one branch, I can go
I have two git branches, A and B, and commits numbered 1 thru 8.
I'd like to be able to tell between two Grit::Commit objects, which is newer.
Given that two branches have diverged and a specific commit from one branch (and

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.