使用.gitignore实际上忽略了一些文件而其他一些文件没有[重复]

问题描述 投票:1回答:2

我的项目是如此结构

root
  .gitignore
  -src
   - config.ts
  -dist
   - config.js

我有一个像这样的.gitignore文件(我只显示前两行)

config.ts
config.js

我看到的是config.ts(显示src文件夹)实际上被忽略而不保存在git上,而config.js(存在于dist文件夹中)不被忽略,而且实际上是保存在git上。

关于我做错了什么的任何建议?

git github
2个回答
2
投票

如果要从git cache中删除所有被忽略的文件并将其推送到origin,请按照以下命令操作:

 git rm -r --cached . 
 git add .
 git commit -m 'Removed all files that are in the .gitignore' 
 git push origin master

你的.gitignore文件是这样的:

dist/config.js

1
投票

config.js可能已经被git跟踪了,应该首先进行跟踪:

git rm dist/config.js
© www.soinside.com 2019 - 2024. All rights reserved.