Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的 Git 存储库中有一些提交的文件,我想从索引中删除它们。但是,我希望能够通过将它们隐藏起来快速将它们带回来,所以稍后我就可以运行,例如git stash apply stash@{0}. 有一些简单的方法可以做到这一点吗?
git stash apply stash@{0}
采用
git rm --cached file_you_want_to_remove
在您要删除的每个文件上,然后提交。这将从您的分支头部删除它们,但是 - 由于您指定--cached- 会将它们留在您的工作树中。(即它们仍然会在您的本地文件系统上可见,但任何从 repo 中提取您的提交的人都不会看到它们。)
--cached
接下来,使用
git stash
像往常一样存储文件。