Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to remove fast many files in Git

Tags:

git

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.

like image 919
Léo Léopold Hertz 준영 Avatar asked Mar 11 '09 19:03

Léo Léopold Hertz 준영


1 Answers

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.

like image 67
VonC Avatar answered Oct 14 '22 05:10

VonC