Q:

Keep part of .gitignore under version control but another part out

I have a .gitignore where I expect that certain parts should be shared across the project but other parts should be individual-specific. How can I achieve this or a similar effect?
My initial thought was to split the .gitignore into two parts, a project-shared and an individual-specific part, where the project-shared part is checked in but the individual-specific part is not. Searching on Google and StackOverflow suggests that there does not exist a splitting/including-other-file mechanism.
Does anyone have a good alternative? Thanks in advance!

A:

Global (cross-repository) .gitignore settings
You can setup a global .gitignore file valid for all Git repositories via the core.excludesfile setting. The setup of this setting is demonstrated in the following code snippet.

Create a ~/.gitignore in your user directory
cd ~/
touch .gitignore

-- Exclude bin and .metadata directories
echo "bin" >> .gitignore
echo ".metadata" >> .gitignore
echo "*~" >> .gitignore
echo "target/" >> .gitignore
# for Mac
echo ".DS_Store" >> .gitignore
echo "._*" >> .gitignore

-- Configure Git to use this file as global .gitignore
git config --global core.excludesfile ~/.gitignore

The global .gitignore file is only locally available.
Local per-repository ignore rules
You can also create local per-repository rules by editing the .git/info/exclude file in your repository. These rules are not committed with the repository so they are not shared with others.
This allows you to exclude, for example, locally generated files

