GIT:如何忽略存储库中已存在的目录而不删除或移动它? [英] GIT : How do I ignore a directory that is already in the repository without deleting or moving it?
问题描述
现在我宁愿完全忽略它。我也想继续工作,所以我不想移动它或删除它。我怎么做到的?
编辑:
我忘了提及我有一个.gitignore文件而且我确实试图添加它,但是这似乎并没有阻止git注意到以前提交中存在的文件的修改。
也许我不是使用正确的模式。
假设该目录名为test,在根目录中,我试过以下内容:
test /
test / *
test *
我很确定你需要从索引中删除文件夹。
git rm -r --cached test /
然后,添加到 .gitignore
test目录,只要 test / *
,假设它在根目录下。
$ b commit git ignore p>
git add .gitignore
git commit -m添加测试目录
检查它是否与 git status
而且应该是这样的:)
Initially I wanted a directory and its contents to be managed in my project. Now I'd prefer it was ignored entirely. I also want to continue working in it, so I don't want to move it or delete it. How do I accomplish this?
edit:
I forgot to mention that I do have a .gitignore file and that I did try to add it, but that doesn't seem to stop git from noticing modifications to files that were present in previous commits.
Maybe I'm not using the right pattern. Assuming the directory is called test, in the root, I've tried the following: test/ test/* test*
I'm pretty sure you need to remove the folder from the index.
git rm -r --cached test/
Then, add to .gitignore
the test directory with just test/*
assuming it is in the root.
Commit git ignore
git add .gitignore
git commit -m "added test directory"
Check to see if it worked with git status
And that should be it :)
这篇关于GIT:如何忽略存储库中已存在的目录而不删除或移动它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!