# Simple git filter-branch --prune-empty --subdirectory-filter foobar/ --tag-name-filter cat -- --all # Complex # (Ref.: http://stackoverflow.com/a/17867910/11895, # http://stackoverflow.com/a/19957874/11895) git filter-branch -f --prune-empty --index-filter \ 'git rm --cached --ignore-unmatch -r -q -- . ; \ git reset -q $GIT_COMMIT -- .gitignore README.md foo/ bar/' \ -- --all