Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove deleted files from git history

I'm trying to split a subproject off of my git repository. However unlike in Detach (move) subdirectory into separate Git repository I don't have it in it's own subdirectory (and moving it in and doing the above only yields the history after the move).

I've cloned the branch from which I want to split off the subproject into it's own repository and removed everything that isn't used by the subproject, so basically I could use this as the repository of my subproject.

Now I want to get rid of the history of all files that are no longer in this repository so as to only keep the file history for the files that made it into the offspring.

I think it must be possible with git-filter-branch but I can't figure out how

Many thanks in advance

like image 709
Niklas Schnelle Avatar asked May 20 '12 18:05

Niklas Schnelle


1 Answers

Here are some instructions to do what you want.

This will remove file_to_remove:

git filter-branch --index-filter 'git rm --cached --ignore-unmatch file_to_remove' --prune-empty -- --all 
like image 138
Neil Forrester Avatar answered Sep 29 '22 06:09

Neil Forrester