无法快速删除Git中的很多文件 [英] Unable to remove fast many files in Git

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

问题描述

通过

  rm!(示例)删除了Git分支中的777个文件 newFeature  

我想提交。
Git让我手动删除每个被删除的文件

  git rm file 

对于所有名称不相似的777文件,编写上述命令需要很长时间。



如何删除Git分支中的这777个文件 newFeature
我想保留它们作为备份使用,但现在,我想要没有它们。

解决方案

  git add -u 

它会删除您删除的所有文件。 Git add



u

--update



只更新git已经知道的文件,为修改提交修改过的内容并将删除的文件标记为删除。

这与 git commit -a 在准备进行提交时的作用类似,只是更新仅限于在命令行中指定的路径。

如果未指定路径,则会更新当前目录及其子目录中的所有跟踪文件。






plumbing way确实是某种 script one-line

  st | grep已删除| awk'{print $ 3}';做git rm $ i;使用GnuWin32完成

或用于Windows的盒子

  git st | grep已删除| gawk{print \git rm \$ 3}| cmd 

但是 git add -u 是主要的瓷器做法。

I removed 777 files which were in Git's branch newFeature by

rm !(example)

I would like to commit. Git ask me to manually remove each of the removed files by

git rm file

It would take a lot of time to write the above command for all 777 files which names are not similar.

How can I remove these 777 files in my Git branch newFeature? I want to keep them as a backup for later use, but now, I want to be without them.

解决方案

git add -u

It will "git delete" all files you removed.

From Git add:

u
--update

Update only files that git already knows about, staging modified content for commit and marking deleted files for removal.
This is similar to what "git commit -a" does in preparation for making a commit, except that the update is limited to paths specified on the command line.
If no paths are specified, all tracked files in the current directory and its subdirectories are updated.


The "plumbing way" was indeed some kind of script one-line

for i in ` git st | grep deleted | awk ‘{print $3}’ ` ; do git rm $i; done

or for Windows box with GnuWin32

git st | grep deleted | gawk "{print \"git rm \"$3}" | cmd

But git add -u is the main porcelain way to do it.

这篇关于无法快速删除Git中的很多文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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