Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
642 views
in Technique[技术] by (71.8m points)

version control - 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...