Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git - Remove All of a Certain Type of File from the Repository

Tags:

git

git-rm

How do I remove all of a certain type of file from the Repository? I'm using

git filter-branch --index-filter 'git rm -rf --cached **/*.jar'

Either git is not expanding globs, or it isn't expanding ** in the way I'm expecting.

like image 930
lmat - Reinstate Monica Avatar asked Aug 10 '16 17:08

lmat - Reinstate Monica


2 Answers

The easiest way I've found is to use the BFG Repo-Cleaner

The instructions on the project page are clear. The command you would use is something like:

bfg --delete-files "*.jar"  my-repo.git

BFG will clean the history of the repo of all files ending in the .jar extension. You can then inspect the result before pushing it back to the server.

like image 39
JoshOfAllTrades Avatar answered Oct 02 '22 15:10

JoshOfAllTrades


You simply have to run this in order to remove all your jars from the index:

git rm -r --cached **/*.jar

Run this command from your root directory of the project and it will clean up and will remove all your file only from the staging area.

like image 145
CodeWizard Avatar answered Oct 02 '22 17:10

CodeWizard