Git中使用.gitignore忽略文件的推送

栏目: 编程工具 · 发布时间: 5年前

内容简介:.gitignore是Git工具的配置文件,用于屏蔽某些文件上传到线上。项目路径下添加.gitignore文件

.gitignore是Git工具的配置文件,用于屏蔽某些文件上传到线上。

1、创建.gitignore

项目路径下添加.gitignore文件

touch .gitignore

Git中使用.gitignore忽略文件的推送

2、编辑.gitignore文件,建立下面的规则

Git中使用.gitignore忽略文件的推送

3、创建个test文件, git status 测试是否忽略

Git中使用.gitignore忽略文件的推送

git status

已经忽略test文件

Git中使用.gitignore忽略文件的推送

配置无效几种情况

  • 命令格式错误
  • 在配置语句的前后面添加空格、Tab、注释等,会导致当前行的配置语句失效
  • 配置语句对已经add、commit的文件无效(.gitignore只能忽略原来没有被追踪的文件,如已被纳入了版本管理中,则修改.gitignore是无效的。)

第三种情况解决办法:删除本地缓存

git rm -r --cached .
git add .

git commit -m 'update .gitignore'

以上所述就是小编给大家介绍的《Git中使用.gitignore忽略文件的推送》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Head First Design Patterns

Head First Design Patterns

Elisabeth Freeman、Eric Freeman、Bert Bates、Kathy Sierra、Elisabeth Robson / O'Reilly Media / 2004-11-1 / USD 49.99

You're not alone. At any given moment, somewhere in the world someone struggles with the same software design problems you have. You know you don't want to reinvent the wheel (or worse, a flat tire),......一起来看看 《Head First Design Patterns》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

MD5 加密
MD5 加密

MD5 加密工具