vscode git 全局忽略文件和文件夹

摘要:windows 中先在当前用户根目录下创建一个全局要忽略的文件列表.gitignore_global,window下 只有扩展名的文件不让保存,可以在 git bash中创建文件;二、 然后在命令行下执行下面git 命令

vscode 的git 默认是没有忽略文件的,需要单配置

一、 windows 中先在当前用户根目录下创建一个全局要忽略的文件列表.gitignore_global

.idea/
.DS_Store
node_modules/
package-lock.json
yarn.lock
.vscode/
.history/
logs/
target/
pid
window下 只有扩展名的文件不让保存,可以在 git bash中创建文件



二、 然后在命令行下执行下面git 命令

git config --global core.excludesfile "%USERPROFILE%\.gitignore_global"

这样就不用在每个项目中都创建 .gitignore 文件了

三、 在使用vscode 时git 忽略的文件可能会编辑器中显示,可以在settings.json 中加入排除选项

    "search.exclude": {        
        "**/node_modules": true,
        "**/bower_components": true,
        "build/": true,
        "temp/": true,
        "library/": true,
        "**/*.anim": true
    },
    "files.exclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,
        "**/*.meta": true,
        "**/.history": true,
        "**/.idea": true,
        "**/idea": true,
        "**/logs": true,
        "**/target": true,
        "**/pid": true,
    }

本文内容仅供个人学习、研究或参考使用,不构成任何形式的决策建议、专业指导或法律依据。未经授权,禁止任何单位或个人以商业售卖、虚假宣传、侵权传播等非学习研究目的使用本文内容。如需分享或转载,请保留原文来源信息,不得篡改、删减内容或侵犯相关权益。感谢您的理解与支持!

链接: https://shenqiku.cn/article/FLY_7784