Git wildcard - delete all instances of a subdirectory

I am trying to run git rm --cached -r <folder> to delete all instances of a folder named .svn recursively. I tried this:

 .svn /.svn /*/.svn /*/*/.svn etc 

And it works, but I'm sure there is a more dynamic way.

thanks

+4
source share
5 answers

The right decision:

 find . -type d -name '.svn' -print0 | xargs -0 git rm --cached -r -- 

@gregor will crash in directories with spaces.

+12
source

find , pipes and xargs are your friends:

 find . -name .svn | xargs git rm -r 
+3
source

If you do not have any changes to your workbook (you can hide them first), there may be an easier way:

 find -type d -name .svn -delete git add -u git commit -m 'remove svn folders -- no idea which maniac would stage them' 

If you want to only disable them, but not physically delete them, go with anton answer :

 find -type d -name .svn -print0 | xargs -0 git rm -r --cached 
+1
source
 find . -name .svn -exec git rm -r --cached {} \; 

There is no need to call xargs unless you need to.

+1
source

This worked for me:

 find . -name '.svn' -print0 | xargs -0 git rm --cached --ignore-unmatch -r -- 

Thanks @ steve76 for --ignore-unmatch

0
source

Source: https://habr.com/ru/post/1400375/


All Articles