As Adrian says this isn't really an issue unless you've got large numbers of binary files in Git that shouldn't be (eg image uploads etc). Personally I wouldn't nuke my history as it's invaluable for debugging, though I'm pretty disciplined about what I commit and how often.
If you want to remove files from your repo that you have previously added, but want to keep a local copy do:
git rm --cached /path/to/remove
This will remove them from the current state of the index and but keep the actual file, which you can then add to your .gitignore. This is handy for files you just added to git by mistake, or for small files that aren't a concern for repo size or security.
However if you've previously committed the files, they will still be in your history, so your total repo size may be inflated (for example if you added a PSD or some large images in the past. If you want to completely remove a file from your history (also handy if sensitive data crept in somehow) you can do:
git filter-branch --index-filter 'git rm --cached --ignore-unmatch <NAME OF FILE>' --prune-empty --tag-name-filter cat -- --all
This command will run the entire history of every branch and tag, changing any commit that involved the file you specify, and any commits afterwards. Commits that are empty afterwards (because they only changed the Rakefile) are removed entirely. Warning: It will overwrite your existing tags as well.
Once you've removed the file you may need to force pushing your changes with a:
git push <remote> <branch> --force
But you want to be pretty sure you're doing the right thing at that point though, as you will overwrite the history on the remote as well, and at that point it really will be gone. There is an excellent, more detailed tutorial here if you go down this route.
但是,当您使用 Beanstalk 时,这不是一个主要问题,因为它只会部署您的文件的最新版本,而不是您的整个 repo/history。