I am trying to execute git rm --cached -r <folder>
to remove all instances of a folder named .svn recursively. I have tried this:
.svn
/.svn
/*/.svn
/*/*/.svn
etc
And it works, but I'm sure there is a more dynamic way.
Thanks
gitignore file is usually placed in the repository's root directory. However, you can create multiple . gitignore files in different subdirectories in your repository.
Just run the rm command with the -f and -r switch to recursively remove the . git folder and all of the files and folders it contains.
The git rm command can be used to remove individual files or a collection of files. The primary function of git rm is to remove tracked files from the Git index. Additionally, git rm can be used to remove files from both the staging index and the working directory.
The right solution would be:
find . -type d -name '.svn' -print0 | xargs -0 git rm --cached -r --
@gregor's will fail on the directories with spaces.
find
, pipes and xargs
are your friends:
find . -name .svn | xargs git rm -r
If you don't have any other changes in your worktree (you can stash them first), there's probably 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 only want to unstage them, but not physically delete them, go with anton's answer:
find -type d -name .svn -print0 | xargs -0 git rm -r --cached
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With