[英]Ignore file removed from local git repo that should stay in other repos
我git克隆了一個arduino草圖,該草圖要求我刪除mv ./libraries $sketchdir/sketch_libraries/
目錄並通過mv ./libraries $sketchdir/sketch_libraries/
將其放置在回購之外。 我無法使用當前目錄編譯該草圖,因此刪除了它。 但是,當我運行git status
它抱怨類庫目錄中缺少內容。
我想告訴git忽略這個目錄故意丟失的事實,並停止困擾我。 我嘗試將libraries/*
添加到.gitignore,但這未能給我所需的結果。
我該怎么做?
如果只想在特定主機上忽略該目錄,請嘗試將目錄路徑添加到.git/info/exclude
而不是.gitignore
:
您的排除文件應如下所示:
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
libraries/*
git status
甚至不會抱怨排除文件已更改。
我只是想知道這里是什么問題。 通過將目錄添加到.gitignore或info / exclude,如果目錄是本地目錄,git不會跟蹤該目錄。 但是在這種情況下,您要在本地刪除它並將其保留在遠程倉庫中,並希望git取消跟蹤該遠程目錄。
為此,您只需運行以下命令:
git update-index --skip-worktree libraries/*
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.