簡體   English   中英

Gitignore 不工作。 我有錯誤的文件路徑嗎?

[英]Gitignore not working. Do I have the wrong file path?

我有一個如下所示的目錄結構:

backend
 - node_modules
 - app.js
.gitignore

我的.gitignore文件如下所示:

./backend/node_modules

但出於某種原因,我的node_modules文件夾仍在上傳到 Github。知道為什么會這樣嗎?

使用.gitignore忽略文件更改僅在文件從未被跟蹤時有效(也就是從未使用 git 添加添加到 git)。

如果你想完全刪除遠程上的更改,update.gitignore with exclusion 並執行以下命令

git rm -r --cached ./backend/node_modules

如果您只是想排除推送更改但不想刪除遠程節點模塊,您可以通過以下命令要求 git 假定上述路徑不變

git update-index --assume-unchanged ./backend/node_modules

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM