惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

A
About on SuperTechFans
MongoDB | Blog
MongoDB | Blog
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Stack Overflow Blog
Stack Overflow Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
aimingoo的专栏
aimingoo的专栏
B
Blog
博客园 - 聂微东
博客园_首页
D
DataBreaches.Net
F
Fortinet All Blogs
小众软件
小众软件
M
MIT News - Artificial intelligence
H
Help Net Security
Microsoft Security Blog
Microsoft Security Blog
The GitHub Blog
The GitHub Blog
大猫的无限游戏
大猫的无限游戏
Apple Machine Learning Research
Apple Machine Learning Research
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
F
Full Disclosure
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
腾讯CDC
Y
Y Combinator Blog
Google DeepMind News
Google DeepMind News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
博客园 - 【当耐特】
Simon Willison's Weblog
Simon Willison's Weblog
云风的 BLOG
云风的 BLOG
A
Arctic Wolf
C
Cyber Attacks, Cyber Crime and Cyber Security
G
Google Developers Blog
B
Blog RSS Feed
Attack and Defense Labs
Attack and Defense Labs
W
WeLiveSecurity
N
News | PayPal Newsroom
Recent Announcements
Recent Announcements
AI
AI
人人都是产品经理
人人都是产品经理
J
Java Code Geeks
V2EX - 技术
V2EX - 技术
TaoSecurity Blog
TaoSecurity Blog
S
Security Affairs
Martin Fowler
Martin Fowler
Webroot Blog
Webroot Blog
P
Palo Alto Networks Blog
S
Schneier on Security
Latest news
Latest news

博客园 - yinsua

OpenBCI调试记录 Qt QML/Quick程序部署 一种CAN接口电路的隔离方案 【转载】0-5V转4-20mA电路以及Howland电流源分析与仿真 【转载】外置USB供电与内置锂电池供电自动切换电路 模块的电气隔离的例子(音频采集电路) 【转载】EMC 共模电感选型 RS485的电路防护设计 ubuntu 20.04 安装VMware Tools Linux常用操作 MOS管随笔 RTX V4随笔 【转载】Keil MDK的sct分散加载文件详解 lua语言 简单类测试 git报错error: could not lock config file RT-Thread速览——内核 ARM MDK开发中的\$Super\$\$main与\$Sub\$\$main - yinsua - 博客园 cpolar(内网穿透工具)安装 VSCode + EIDE开发记录
Git 加入gitignore文件后应用
yinsua · 2024-10-10 · via 博客园 - yinsua

现有项目中加入gitignore文件后需要清除缓存才能使gitignore文件生效,从而屏蔽掉指定文件/夹,执行如下命令即可:
git rm --cached -r <dist-folder>
然后执行git add .添加当前文件,提交代码:git commit -m "XXXXXXX"


参考:https://www.cnblogs.com/yalong/p/14986408.html
由于特殊原因,把.gitignore文件下 /dist 注释了,也就是把dist 文件添加到git仓库里了,
现在又不想添加到git仓库里了,但是把/dist 注释放开还不行,就是.gitignore失效了,查阅资料才知道
.gitignore 只对未跟踪的文件起作用!

已跟踪的文件是指那些被纳入了版本控制的文件,在上一次提交中有它们的记录。那么未跟踪文件就是指那些从没提交过的文件。

因为上次已经把/dist 整个提交上去了,所以这时候.gitignore已经不行了

要想实现git 忽略dist文件夹,需要下面几个步骤

1.取消文件跟踪

git rm 或者 git rm --cached
git rm : 同时从工作区和索引中删除文件。即本地的文件也被删除了。
git rm --cached:从索引中删除文件,但是本地文件还存在, 只是不希望这个文件被版本控制。
这里我使用第二个,具体用法就是 git rm --cached -r dist
-r 的意思是递归处理,如果不加 -r的话,会报错
如果取消某个文件的跟踪,可以不用 -r 直接 git rm --cached dist/index.less

2.把 gitignore 提交上去

git add .
git commit -m '修改gitignore'
git push

以后本地dist目录下文件再变的话,也不会被跟踪到了,其他小伙伴,只需git pull 一下就可以