Source
These are my notes from reading very nice blog post Git Ignore vs Git Exclude.
Note methodology
I’ve used Jeffrey Kaplan’s methodology for notes.
Notes
git excludeisn’t widely recognized asgit ignore- Articles covers when and how to use
git exclude - This article is about
git excludeone of the two similar functions: ignore and exclude - To simplify this article, author is going to skip the
gitprefix and useignoreandexclude - Article is about
git excludeand how it is related togit ignore - The goal of these two functions is similar, they even share the same help page
- Commands have the same interface and similar function but they are not the same
- Two differences, file location and list of tracking files
- As these two functions are very similar and track information about ignored file, for git they provide different approach of keeping it persistent
git excludehelps keeping the ignored files for given location, it’s not ment to be shared,git ignoreis a way to persist ignored files for every git repository instance.- We can tell git to don’t track some files using two functions:
ignoreandexclude, usage depentes on the result, public or private exclusion - We can use global ignore files to exclude files in all repositories
- We have, in total, three ways to exclude files: repository’s ignore, repository’s exclude and global ignore
- When I only want to hide file for myself - exclude, for everyone - ignore, ignored in many repositories on one machine - global ignore