Skip to content

Instantly share code, notes, and snippets.

@andrewle
Created October 2, 2009 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewle/199991 to your computer and use it in GitHub Desktop.
Save andrewle/199991 to your computer and use it in GitHub Desktop.
Add all removed files in a git tree to the index with 'git rm'
#!/usr/local/bin/ruby -w
# Find any deleted but not index files in the git status output
# and add them to the index using the 'git rm' command
# USAGE: gir
`git status`.each do |s, flag|
flag = true if s.include? '# Changed but not updated:'
`git rm #{s.gsub(/#.*deleted:\s*/, '')}` if s.include? 'deleted:'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment