huggie huggie - 1 year ago 89
Git Question

Git rm all that says "deleted by us" during a merge

During a merge, sometimes there are within unmerged paths, there will be multiple files which says "deleted by us". If I want to keep them deleted, each one needs

git rm

How do I do that with one command instead of using
git rm
on each file?

j_4 j_4
Answer Source

Just use other Linux tools! That's what the terminal is for

grep -rl "deleted by us" | xargs git rm

If you want to only affect the files listed by git status, you can try:

git status --porcelain | cut -c4- | xargs grep -l "deleted by us" | xargs git rm


Give the output in an easy-to-parse format for scripts. This is similar to the short output, but will remain stable across Git versions and regardless of user configuration.

You could filter with sed/awk rather than just using cut for finer control over what you pass in.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download