Skip to content

Instantly share code, notes, and snippets.

@olistik
Created March 2, 2012 08:52
Show Gist options
  • Save olistik/1956924 to your computer and use it in GitHub Desktop.
Save olistik/1956924 to your computer and use it in GitHub Desktop.
Stage/unstage deleted files in a git project
#!/bin/bash
# Performs a git rm on every deleted file.
deletion_list=$(git status | grep deleted: | cut -c 15-)
for file in $deletion_list; do
git rm --ignore-unmatch $file
done
#!/bin/bash
# Unstage files staged with 'git rm'.
deletion_list=$(git status | grep deleted: | cut -c 15-)
for file in $deletion_list; do
git reset HEAD $file
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment