首页 > 其他 > 详细

git 修改 .gitignore 不生效

时间:2021-06-07 09:25:08      阅读:17      评论:0      收藏:0      [点我收藏+]

    在使用 Git 时候,发现在 .gitignore 文件中添加内容后,推送成功后并没有生效。

出错原因:

.gitignore 文件的内容不对历史文件生效

情景复现:

1. 远端已经有了 .idea 配置文件夹
2. 在 .gitignore 中添加 .idea
3. commit && push 这个 .gitignore 文件的更改
4. 发现远端仓库中仍有 .idea 的文件夹,并未被忽略掉

解决方法:

// 清除本地缓存
git rm -r --cached .

// 重新 trace file
git add.

// 重新提交
git commit -m "update .gitignore"

// 推送远端
git push origin master

 

参考资料:

https://blog.csdn.net/mingjie1212/article/details/51689606

git 修改 .gitignore 不生效

原文:https://www.cnblogs.com/zpcoding/p/14857035.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!