Skip to content

Instantly share code, notes, and snippets.

@sjmulder
Created November 7, 2012 14:14
Show Gist options
  • Save sjmulder/4031842 to your computer and use it in GitHub Desktop.
Save sjmulder/4031842 to your computer and use it in GitHub Desktop.
Quickly search through a reflog
#!/usr/bin/ruby
# Some bash-fu should be able to do the same but I'm only a white belt
if ARGV.length < 1
$stderr.puts 'usage: lostfind <keyword> [<keyword> ...]'
else
reflog = `git reflog`
reflog.each_line do |line|
hash, _, message = line.split(' ', 3)
data = `git show #{hash}`
if ARGV.any? { |arg| data.include?(arg) }
puts line
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment