当前位置:   article > 正文

git中忽略文件的配置_git忽略配置文件

git忽略配置文件

一、在项目根目录下创建.gitignore文件

.DS_Store
node_modules/
/dist


# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

二、配置规则

/mtk/ 过滤整个文件夹,例:node_modules/
ip *.z 过滤zip后缀文件
/mtk/do.c 过滤该文件,例:demo.html
前面加 !,表示不过滤此项,例:!src/ 或者 !*.js 或者 !index.html
  • 1
  • 2
  • 3
  • 4

链接: https://www.cnblogs.com/wangRong-smile/articles/11607458.html

如果在配置之前已经提交过文件了,要删除提交过的,如何修改,参考下面的

git rm --cached .DS_Store

用于从 Git 的暂存区(Index)中删除 .DS_Store 文件,同时保留工作目录中的该文件。.DS_Store 是 macOS 系统生成的隐藏文件,通常用于存储文件夹的自定义属性和显示设置。
通过使用 git rm --cached .DS_Store 命令,您可以将 .DS_Store 文件从 Git 的版本控制中移除,但不会删除实际的文件。这可以是为了避免提交 macOS 特定的系统文件到代码库中。
请注意,执行该命令后,Git 将不再跟踪 .DS_Store 文件的更改。如果您不希望在项目中包含 .DS_Store 文件,建议将其添加到您的 .gitignore 文件中,以便永久性地忽略这些文件。

如果您有任何其他需要帮助或疑问,请随时告诉我。
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/神奇cpp/article/detail/888400
推荐阅读
相关标签
  

闽ICP备14008679号