How do I configure git to ignore some files locally?

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

    Add the following lines to the [alias] section of your .gitconfig file

    ignore = update-index --assume-unchanged
    unignore = update-index --no-assume-unchanged
    ignored = !git ls-files -v | grep "^[[:lower:]]"
    

    Now you can use git ignore my_file to ignore changes to the local file, and git unignore my_file to stop ignoring the changes. git ignored lists the ignored files.

    This answer was gleaned from http://gitready.com/intermediate/2009/02/18/temporarily-ignoring-files.html.

提交回复
热议问题