Can I make a user-specific gitignore file?

GitVersion ControlGitignore

Git Problem Overview


I want to change the gitignore, but not everyone on the team wants these changes. How can a user have their own specific git ignore file?

Git Solutions


Solution 1 - Git

You can create your own .gitignore using

git config --global core.excludesfile $HOME/.gitignore

Then put your desired entries in that file.

Solution 2 - Git

For user-specific and repo-specific file ignoring you should populate the following file:

$GIT_DIR/info/exclude

Usually $GIT_DIR stands for:

your_repo_path/.git/

Solution 3 - Git

In their .gitconfig:

[core]
    excludesfile = ~/.global_gitignore

That way, they can ignore certain types of files globally. Each user can have their own global ignore file.

Solution 4 - Git

For example, you want ignore ~/some/path/.idea folder:

# 1. Add .idea to user specific gitignore file
echo .idea > ~/.gitignore

# 2. Add gitignore file to gitconfig
git config --global core.excludesfile ~/.gitignore

Solution 5 - Git

As indicated in Atlassian's .gitignore tutorial, you could also use your repo's <repo>/.git/info/exclude file that you can easily edit with any text editor. It works the same as .gitignore.

I could easily ignore my intelliJ files, personal dockerfiles and stuff only I need to work with.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionasdsadasdsView Question on Stackoverflow
Solution 1 - GitDave KincaidView Answer on Stackoverflow
Solution 2 - GitgrzuyView Answer on Stackoverflow
Solution 3 - GitRafe KettlerView Answer on Stackoverflow
Solution 4 - GitSergey ZhigalovView Answer on Stackoverflow
Solution 5 - Gitobscure18View Answer on Stackoverflow