timeSmith
timeSmith

Reputation: 572

How can I Remove .iml files from a Git repository?

How can I keep everyone's .iml files out of an existing git project?

(I'm on a Mac)

Upvotes: 0

Views: 3999

Answers (2)

timeSmith
timeSmith

Reputation: 572

remove all existing offenders:

find . -name "*.iml" -print0 | xargs -0 git rm -f --ignore-unmatch

then add *.iml .gitignore:

echo *.iml >> .gitignore
git add .gitignore

and commit the change:

git commit -m '.iml banished!'

It's also possible to do this all at once:

find . -name "*.iml" -print0 | xargs -0 git rm -f --ignore-unmatch; echo *.iml >> .gitignore; git add .gitignore; git commit -m '.iml banished!'

Answer modified from benzado and Chris Redford's excellent answer https://stackoverflow.com/a/107921/2570689 to How can I Remove .DS_Store files from a Git repository?

Upvotes: 3

Pascal S
Pascal S

Reputation: 121

git rm supports wildcards (and globs). So you could do

git rm -r 'src/*.iml'

and be done (obviously, substitute whatever folder the iml files are in for 'src')

Upvotes: 2

Related Questions