git 如何从暂存区中删除目录子树?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5359830/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I remove a directory subtree from the staging area?
提问by Acorn
I made a new repository, and ran git add -A
. I then noticed that there was a folder containing about 100 files that shouldn't have been included, so I added it to .gitignore
.
我创建了一个新的存储库,然后运行git add -A
. 然后我注意到有一个文件夹包含大约 100 个不应该包含的文件,所以我将它添加到.gitignore
.
How do I now clear the staging area so that I can add
all my files again taking into account the updated .gitignore
?
我现在如何清除暂存区,以便我可以add
再次考虑更新的所有文件.gitignore
?
回答by Greg Bacon
In #git, you said you unintentionally added a directory that should have been ignored, so run
在#git 中,你说你无意中添加了一个应该被忽略的目录,所以运行
git rm --cached -r directory-name
to recursively remove the tree rooted at directory-name
from the index.
以递归方式directory-name
从索引中删除以 at为根的树。
Don't forget to update .gitignore
!
不要忘记更新.gitignore
!
回答by Matthew Flaschen
You can just use the command:
你可以只使用命令:
git reset
回答by Busilinks
Make sure you remember to put the s
in --global core.excludesfile .gitignore.txt
一定要记住把s
在--global core.excludesfile .gitignore.txt
excludesfile
vs excludefile
excludesfile
对比 excludefile
Maybe this will save someone else the hour I lost...
也许这会为别人节省我失去的时间......