从已从磁盘中删除的 Git 存储库中删除多个文件 [英] Removing multiple files from a Git repo that have already been deleted from disk

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

问题描述

我有一个 Git 存储库,我使用 rm(not git rm)删除了四个文件,我的 Git 状态看起来像这个:

I have a Git repo that I have deleted four files from using rm (not git rm), and my Git status looks like this:

#    deleted:    file1.txt
#    deleted:    file2.txt
#    deleted:    file3.txt
#    deleted:    file4.txt

如何从 Git 中删除这些文件而不必像这样手动添加每个文件:

How do I remove these files from Git without having to manually go through and add each file like this:

git rm file1 file2 file3 file4

理想情况下,如果可能的话,我正在寻找与 git add . 相同的工作方式.

Ideally, I'm looking for something that works in the same way that git add . does, if that's possible.

推荐答案

For Git 1.x

$ git add -u

这告诉 git 自动暂存跟踪的文件——包括删除以前跟踪的文件.

This tells git to automatically stage tracked files -- including deleting the previously tracked files.

暂存整个工作树:

$ git add -u :/

仅暂存当前路径:

$ git add -u .

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

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