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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 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 一下就可以