暂存已删除的文件 [英] Staging Deleted files

查看:100
本文介绍了暂存已删除的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我在我的git仓库中有一个名为 foo 的文件。



假设它已被 rm (不是 git rm )。然后git status会显示:

 没有为commit提交的更改:

deleted:foo

如何分阶段删除这个文件?



如果我尝试:

  git add foo 

它表示:

 'foo'与任何文件都不匹配。 


解决方案使用 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

这篇关于暂存已删除的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆