Skip to main content
added clarifying note about command in the pipeline and macOS
Source Link
masukomi
  • 143
  • 1
  • 1
  • 8

assuming the problem is

I deleted a bunch of things without using git rm. How do I delete them all from git without manually typing git rm <file path> again and again?

git status | grep "deleted: " | tr "\t" " " | sed -e "s/ *deleted: */git rm /" | bash

Note: the tr in the pipe is used because sed on the mac doesn't respect the \t character so you need to get rid of it first, or install GNU sed and use that. The line output by git (at the time of writing) starts with \tdeleted: Sadly, tz doesn't appear to come with macOS either. You'll want to install that with homebrew because it really helps out in a lot of situations.

assuming the problem is

I deleted a bunch of things without using git rm. How do I delete them all from git without manually typing git rm <file path> again and again?

git status | grep "deleted: " | tr "\t" " " | sed -e "s/ *deleted: */git rm /" | bash

Note: the tr in the pipe is used because sed on the mac doesn't respect the \t character so you need to get rid of it first, or install GNU sed and use that. The line output by git (at the time of writing) starts with \tdeleted:

assuming the problem is

I deleted a bunch of things without using git rm. How do I delete them all from git without manually typing git rm <file path> again and again?

git status | grep "deleted: " | tr "\t" " " | sed -e "s/ *deleted: */git rm /" | bash

Note: the tr in the pipe is used because sed on the mac doesn't respect the \t character so you need to get rid of it first, or install GNU sed and use that. The line output by git (at the time of writing) starts with \tdeleted: Sadly, tz doesn't appear to come with macOS either. You'll want to install that with homebrew because it really helps out in a lot of situations.

Source Link
masukomi
  • 143
  • 1
  • 1
  • 8

assuming the problem is

I deleted a bunch of things without using git rm. How do I delete them all from git without manually typing git rm <file path> again and again?

git status | grep "deleted: " | tr "\t" " " | sed -e "s/ *deleted: */git rm /" | bash

Note: the tr in the pipe is used because sed on the mac doesn't respect the \t character so you need to get rid of it first, or install GNU sed and use that. The line output by git (at the time of writing) starts with \tdeleted: