Take the 2-minute tour ×

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 http://stackoverflow.com/questions/930612/git-remove-oldest-revisions-of-a-file

Completely remove (old) git commits from history http://stackoverflow.com/questions/4987341/completely-remove-old-git-commits-from-history

How do you remove a specific revision in the git history? http://stackoverflow.com/questions/37219/how-do-you-remove-a-specific-revision-in-the-git-history

share|improve this question
add comment

1 Answer

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
add comment

Your Answer


