How do I configure git to ignore some files locally?

前端 未结 11 925
深忆病人
深忆病人 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:52

    You have several options:

    • Leave a dirty (or uncommitted) .gitignore file in your working dir (or apply it automatically using topgit or some other such patch tool).
    • Put the excludes in your $GIT_DIR/info/exclude file, if this is specific to one tree.
    • Run git config --global core.excludesfile ~/.gitignore and add patterns to your ~/.gitignore. This option applies if you want to ignore certain patterns across all trees. I use this for .pyc and .pyo files, for example.

    Also, make sure you are using patterns and not explicitly enumerating files, when applicable.

提交回复
热议问题