Reputation: 426
I need to remove a folder from my repo in certain commits. It was added in commit a
and removed in commit b
and was added again in commit c
as submodule.
Now I want to remove it from the commits between (including) a
and b
.
I have it as far as I have to do something like:
git filter-branch --index-filter 'git update-index --remove lib --ignore-submodules' 7a08959f87681decc15ad5a272bbada66c3272e8 goodbye_cmake
But I don't know how I can add the end (b
). It deletes it from all the commits from a
to the last commit of goodbye_cmake (i.e. HEAD)... So what do I have to change that I still have my submodule in the last few (~30) commits?
Thanks for all your time!
- Fodinabor
Upvotes: 0
Views: 416
Reputation: 663
Unless I am misunderstanding the question, you already have the answer (almost):
$ git filter-branch --index-filter 'git update-index --remove tests/files/ceac_analysis_data_* --ignore-submodules' 10e8e892b49a4657a3b36ef4ca0a524b8a26a438..HEAD
So the syntax is
$ git filter-branch *options* a..b
Instead of
$ git filter-branch *options* a b`
Upvotes: 0
Reputation: 426
BFG is a nice alternative to filter-branch, and it's blessed by github. It only changes your history and won't remove any files currently in the project, so it should remove the old directory up to commit b
like you want. The invocation will end up looking like:
java -jar bfg.jar --delete-folders directory_name your_repo.git
Upvotes: 1