views:

107

answers:

2

I'm working on a django project with a few other developers and we have recently realized that all the .pwc files in our app cause the commits and repository to be cluttered.

Is there any way I can remove all .pwc files from all child directories in my git repository and then ignore them for any future commit?

+3  A: 

Plenty of ways to remove them:

git ls-files | grep '\.pwc$' | xargs git rm

find . -name *.pwc | xargs git rm

Note: If you haven't committed them, just use rm, not git rm.

To ignore them in the future, simply add *.pwc to the .gitignore. (If you don't have one, create a file named .gitignore at the top level of your repository, and just add a single line saying "*.pwc")

Jefromi
I did later set up a .gitignore but will *.pwc keep them ignored for every directory level of the app?
BenMills
The .gitignore is respected in all subdirectories of the one where it's found. This is why they're generally placed at the top level. Note that you can put them at lower levels, if you'd like to have ignore rules only for a given subdirectory.
Jefromi
+1  A: 

Jefromi's answer will remove them for the present and the future...you could also remove them in the past using git filter-branch. Of course this has some other ramifications, like requiring everyone else working on the repo to re-checkout (and possibly rebase any work they haven't pushed to the main repo). Depends how big the PWC files are, you may want to do this if they are wasting a lot of diskspace in your repo (since every time you clone a git repo, you get every file and every revision)

davr