Can I make a user-specific gitignore file?

2019-01-07 08:10发布

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?

4条回答
闹够了就滚
2楼-- · 2019-01-07 08:26

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
查看更多
何必那么认真
3楼-- · 2019-01-07 08:31

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/

查看更多
【Aperson】
4楼-- · 2019-01-07 08:36

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.

查看更多
乱世女痞
5楼-- · 2019-01-07 08:38

You can create your own .gitignore using

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

Then put your desired entries in that file.

查看更多
登录 后发表回答