Excluding files from git

Three very useful ways to eclude files and folders from git:

  1. Add a .gitignore file to your home directory and add files and folders you want all of your local git repos to ignore. For example: My .gitignore file.

  2. Add a .gitignore file to your local repo, stage, and commit the file as part of your codebase. This is very handy if you want to share a common set of files/folders to ignore with others working with the same upstream repo.

  3. Add files and folders to .git/info/exclude. The exclude file is found in every git repo and allows you to set ignore rules that will only work for your local repo. It will not get sent upstream during a push.

Checkout this excellent github help page for more details and examples!

Blog Category: