Ignoring Files Locally in Git

I wanted to keep some WordPress plugins on my local installation of WordPress that did not end up on my live server: mostly debugging tools (for example: 1, 2 and 3). I could have essentially added them to git ignore but let’s look past that. Luckily there’s a fairly painless way to do so on a local machine (this is written from the vantage of a Linux terminal):

  1. cd into your .git directory typically resides your base directory (note dotfiles may be hidden).
  2. From your .git directory cd into the info directory.
  3. Use the text editor of your choosing to edit the file “exclude” in the info directory.
  4. Add the specific paths that you wish to exclude.
  5. Here’s what my exclude file looks like for the aforelinked plugins to be excluded:
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~




Leave a Reply