Git – automagically add modified files and rm deleted files

Sometimes a script will upgrade/add/modify/delete a large swath of files (possibly due to an upgrade-type script). If you are lazy, then you’ll want a script to help you commit those files. Here’s what I’ve come up with:

To perform a git add to all modified files:
[bash]
for file in `git status | grep modified | cut -d ":" -f 2`; do git add $file; done
[/bash]

To perform a git rm to all modified files:
[bash]
for file in `git status | grep deleted | cut -d ":" -f 2`; do git rm $file; done
[/bash]

Leave a Reply

Your email address will not be published. Required fields are marked *