gitgit-stagegit-cleangit-rm

Git: need to recursively 'git rm' the contents of all bin and obj folders


Someone by accident just commited all of their bin and obj folders to our repo (there are around 40 such folders). I would like to do a git rm -r on all of these folders. Is there a command to do this?


Solution

  • Have backups,

     find . -type d -name bin -exec git rm -r {} \;
    
     find . -type d -name obj -exec git rm -r {} \;
    

    Update

    With bash, you can set the shopt globstar, and be happy:

     shopt -s globstar
     git rm -r **/{obj,bin}/
    

    Finally, if you need to remove these from the history of the repository, look at git filter-branch and read the section on 'Removing Objects' from the Pro Git Book