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 that would get pushed upstream, so I essentially needed to locally exclude these files/directories. Luckily there’s a fairly painless way to do so on a local machine (this is written from the vantage of a Linux terminal):
- cd into your .git directory typically resides your base directory (note dotfiles may be hidden).
- From your .git directory cd into the info directory.
- Use the text editor of your choosing to edit the file “exclude” in the info directory.
- Add the specific paths that you wish to exclude.
- 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] # *~ plugins/debug-bar plugins/debug-objects plugins/debug-queries