Git Tip: Removing .gitignore’d Files after adding to .gitignore

4 · 24 · 13

Very handy trick for removing .gitignore’d files from a repo AFTER those files previously had been included in the repo:

git rm --cached `git ls-files -i --exclude-from=.gitignore`

Now commit the deletion(s):

git commit -m 'Repo pruned - Removed all files that are in the .gitignore'

And if you need to sync with a remote, push it:

git push origin master

And PRESTO – repo is cleaned up without modifying files.

h/t Blundell here

Latest Articles

Digital Marketing Tips for Artisan Coffee Shops

Artisan coffee is a growth industry. Millions of people are rediscovering their love of freshly ground coffee and on every street in every town, there is at least one artisan coffee shop staffed by cool hipsters. With growth in this niche phenomenal, it can be hard to...

read more

Ways to Use Press Releases for SEO Purposes!

When a company has some news that it wants to share with the media, it uses a press release. For decades, this method of disseminating company news has been utilized successfully. Thanks to the Internet, press releases can be conducted on a digital platform and...

read more

Considerations when reviewing Analytics Data

Questions to Ask of Analytics Data Do you know how to succeed in business using SEO? One must have a fair idea about how search engines operate. Using the data reporting and analysis efficiently and responding to it is of utter importance. With a proper response to...

read more

Learning ES6 (FINALLY)

Some amazingly great changes are in ES6, but I wanted to start out simple by highlighting a very useful syntax introduction: the let command. In a nutshell, let introduces block-level scoping to variables. What does that mean? I'll show you: <script> var x = 10;...

read more