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

查看:676
本文介绍了从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

理想情况下,我正在寻找一些与<$如果可能的话,c $ c> 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天全站免登陆