[英]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.