Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to permanently delete an old revision (or revisions) of single file from Git. Specifically, I want to delete from my public git server repo my initial published version of one single file, but keep the rest of its revisions. How can I do that?

I've done some searching, as follows. But none of them seem to answer my specific question. Please help.

Thanks a lot!

git remove oldest revisions of a file

Completely remove (old) git commits from history

How do you remove a specific revision in the git history?

share|improve this question

If the history is simple (linear), a git rebase -i should do (the other alternatives will essentially do the same). If you have several branches, you will have to regraft them onto the master branch at the correct points (your "rewrite one early commit" will only afect the branch you modify, others will just retain the original history).

I'd do this (dangerous) experiments on a clone, and replace the original when done and verified correct. Please note that any external clones will get royally confused by the changed history, the only reasonable course of action is to re-clone each.

share|improve this answer
Thanks @vonbrand. I found someone else gave a short suggestion of using "git rebase -i", but due to lack of details, I found it only works for un-commented staging changes, and it seems to shorten history of a whole project, rather than a single file. – xpt Mar 2 '13 at 14:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .