Skip to content

Instantly share code, notes, and snippets.

@digitalronin
Created July 22, 2008 13:36
Show Gist options
  • Save digitalronin/948 to your computer and use it in GitHub Desktop.
Save digitalronin/948 to your computer and use it in GitHub Desktop.
Ruby script to automatically "git rm" deleted files
#!/usr/bin/env ruby
# Ruby script to automatically "git rm" deleted files
DELETED_REXP = /^#\s+deleted:\s+(.*)/
MARKER_LINE = '# Changed but not updated:'
lines = `git status`
found_marker = false
lines.split("\n").each do |line|
found_marker = true if line == MARKER_LINE
next unless found_marker
if line =~ DELETED_REXP
`git rm #{$1}`
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment