Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove and ignore all files that have an extension from a git repository

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?

like image 201
BenMills Avatar asked Feb 23 '10 19:02

BenMills


People also ask

How do I exclude files from a Git repository?

Open the . git/info/exclude file in a text editor and add the folder to ignore. This file remains private to you.

How do you exclude or ignore some files from Git commit?

Set “–assume-unchanged” to a path to exclude to check on git commit and it will exclude your file from git commit. You will need to use the git update-index and –assume-unchanged to exclude files from git commit.

What is Gitignore file extension?

A file with the GITIGNORE file extension is a Git Ignore file used with the version/source control system called Git.


1 Answers

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")

like image 139
Cascabel Avatar answered Sep 22 '22 22:09

Cascabel