Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tell Sublime Text to ignore everything in .gitignore?

Vim has this great plugin to convert the current project's .gitignore into a syntax understandable by Vim and from there exclude all those files from opening.

Using Sublime Text 3's 'Go to Anything' (CMD+P), I get lots of files I'm not interested in, such as stuff under .build and .meteor.

Is there something similar for ST3?

like image 904
Jonatan Littke Avatar asked Aug 28 '13 08:08

Jonatan Littke


People also ask

How ignore all Gitignore?

If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a . gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.

How do I ignore a .gitignore class file?

The easiest and most common way to ignore files is to use a gitignore file. Simply create a file named . gitignore in the repository's root directory. Then, add names and patterns for any files and directories that should not be added to the repository.

How do I ignore a folder in Gitignore?

If you want to maintain a folder and not the files inside it, just put a ". gitignore" file in the folder with "*" as the content. This file will make Git ignore all content from the repository.

Why files in Gitignore are not ignored?

gitignore ignores only untracked files. Your files are marked as modified - meaning they were committed in the past, and git now tracks them. To ignore them, you first need to delete them, git rm them, commit and then ignore them.


1 Answers

I created a quick-and-dirty plugin, sublime-gitignorer, to solve exactly this problem.

It is currently tested on Ubuntu and Windows in Sublime Text 2 and 3. I expect it will also work on any other Linux distro or on Mac.


To install, assuming you have package control, just:

  • Press CTRL+SHIFT+P (CMD+SHIFT+P on Mac)
  • Select "Install Package"
  • Search for the Gitignored File Excluder and press Enter.

Alternatively, if you don't have package control you can copy gitignore_plugin.py to your Packages directory, which you can locate by selecting Browse Packages... from the Preferences menu in Sublime. You should really get Package Control instead, though - it's useful.


I'm not kidding when I say this plugin is dirty. The way it works is that the plugin, every five seconds:

  • Checks for Git repos located within your open folders
  • Asks Git what paths are ignored in each of those repos
  • Adds those paths to the file_exclude_patterns and folder_exclude_patterns settings.

Seems to work okay for most users, though - at least as long as the folders you're opening in Sublime aren't too huge. The presence of giant folders (e.g a typical node_modules folder) can, in combination with this plugin, slow Sublime to a crawl.

Anyone looking to contribute or report bugs should check out the issues page.

like image 144
Mark Amery Avatar answered Oct 13 '22 02:10

Mark Amery