2016-10-20 137 views
1

無論出於何種原因,我的.gitignore未能忽略我的node_modules目錄。當我執行git status時,它會返回一堆已刪除和已修改的文件,這些文件位於它應該忽略的目錄下,並且沒有選擇自上次提交後添加的文件。破壞我的本地git回購

我在做什麼錯?

回購是here

.gitignore是在這裏:

node_modules 
.idea 

# compiled output 
/public/vendor/my-app/dist 
/public/vendor/my-app/tmp 

# dependencies 
bower_components 

# IDEs and editors 
/.idea 

# misc 
/public/vendor/my-app/.sass-cache 
/public/vendor/my-app/connect.lock 
/public/vendor/my-app/coverage/* 
/public/vendor/my-app/lib/peerconnection.log 
/public/vendor/my-app/npm-debug.log 
/public/vendor/my-app/testem.log 
/public/vendor/my-app/typings 

# e2e 
/public/vendor/my-app/e2e/*.js 
/public/vendor/my-app/e2e/*.map 

#System Files 
.DS_Store 

有什麼事我可以粘貼會有所幫助?

+0

您的回購鏈接是404 gitignore絕對是您項目的根源嗎? – GreensterRox

+0

是的,但在另一個目錄中有另一個.gitignore。他們會衝突嗎? – gh0st

+0

它未拾取的文件位於何處? –

回答

1

您已在子目錄node_modules跟蹤文件。將一個目錄添加到.gitignore文件不會解除對這些文件的查找。你必須自己做。

使用

git rm --cached -r node_modules 

和跟進提交給刪除node_modules所有文件。使用--cached,它們只能從git中刪除(特別是索引,並且在壓縮之後),而不是從文件系統中刪除。

對於問題的第二部分,您提供的意見讓我得出結論:您正在使用submodule功能,而目錄public/vendor實際上是一個子模塊。請參閱git文檔here。您不能將子模塊中的文件添加到主git存儲庫,因爲這會破壞原始repo和子模塊之間的區別。

+0

所以在我運行'git rm --cached -r node_modules'後,我做了一個'cd node_modules',然後'rm -rf *'。之後,我做了一個'git status',所有這些文件仍然顯示爲等待提交刪除。我必須承諾嗎?另外'public/vendor'下的其他文件沒有顯示出來。任何想法發生了什麼? – gh0st

+0

好的,所以你想擺脫'node_modules'中的所有文件,即使在你的文件系統中。你可以省略'--cached'標誌,它會在沒有額外的'rm -rf'的情況下完成你想要的。你必須提交文件刪除,是的。現在,這些文件將在您的索引和工作目錄中被刪除。您必須提交這些刪除操作才能將其刪除(刪除)到存儲庫中。 –

+0

我寧願忽略我的'node_modules'目錄。 – gh0st