How do I configure git to ignore some files locally?

前端 未结 11 1109
深忆病人
深忆病人 2020-11-22 01:03

Can I ignore files locally without polluting the global git config for everyone else? I have untracked files that are spam in my git status but I don\'t want to commit git c

11条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 01:39

    You can simply add a .gitignore file to your home directory, i.e. $HOME/.gitignore or ~/.gitignore. Then tell git to use that file with the command:

    git config --global core.excludesfile ~/.gitignore
    

    This is a normal .gitignore file which git references when deciding what to ignore. Since it's in your home directory, it applies only to you and doesn't pollute any project .gitignore files.

    I've been using this approach for years with great results.

提交回复
热议问题