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?

  • Git stage and commit - what happens to uncommitted files upon reverting?
  • GIT stage and commit only files with a certain file ending
  • Git diff doesn't show changes for new added files
  • git undo deleted files
  • Git: prevent staging some files, automatically stage all
  • Smartgit/hg not listing changed files
  • How do I move an unstaged file to untracked?
  • Getting Git-concept of “stage”
  • 3 Solutions collect form web for “Git: need to recursively 'git rm' the contents of all bin and obj folders”

    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

    Once you revert (will keep files in history) or reset the commit,

    git reset --hard
    

    Once these are ignored files,

    git clean -xdf
    

    I use that to clean up before rebuilding a solution. Seems vs uses some dlls even after a checkout of a different branch or a merge.

    You shouldn’t need to resort to filter branch. Interactive rebase will do. Remember the –preserve-merges flag.

    Hope this helps.

    Another option is to revert the offending commit with git revert.

    Git Baby is a git and github fan, let's start git clone.