Can I make a user-specific gitignore file?

爷,独闯天下 提交于 2019-11-27 03:24:51

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/
Dave Kincaid

You can create your own .gitignore using

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

Then put your desired entries in that file.

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.

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
obscure18

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!