本文介绍了暂存已删除的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我在我的git仓库中有一个名为使用 git rm foo 将文件分阶段删除。 (这也会将文件从文件系统中删除,如果它以前没有被删除过的话,它当然可以从git中恢复,因为它之前已经被检入过。)要将文件暂存而不从文件系统中删除,请使用 git rm --cached foo
Say I have a file in my git repostiory called foo.
Suppose it has been deleted with rm (not git rm). Then git status will show:
Changes not staged for commit: deleted: foo
How do I stage this individual file deletion?
If I try:
git add foo
It says:
'foo' did not match any files.
解决方案
Use git rm foo to stage the file for deletion. (This will also delete the file from the file system, if it hadn't been previously deleted. It can, of course, be restored from git, since it was previously checked in.)
To stage the file for deletion without deleting it from the file system, use git rm --cached foo
这篇关于暂存已删除的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!