Skip to content

Instantly share code, notes, and snippets.

@joshuaflanagan
Created June 27, 2012 01:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshuaflanagan/3000618 to your computer and use it in GitHub Desktop.
Save joshuaflanagan/3000618 to your computer and use it in GitHub Desktop.
See what's going on in your .git folder when you perform git commands
# I used this to monitor changes to the .git folder during
# my Austin on Rails lightning talk on Understanding Git.
#
# I ignore any changes to the .git/logs folder, because they are
# noisy and don't add a lot to understanding.
# If you want "the whole truth", remove the :ignore parameter below.
#
# ruby listen.rb <path to .git folder>
#
# gem install listen # its the foundation of Guard
require 'listen'
path_to_watch = ARGV[0] || '.'
last_change = Time.now
Listen.to(path_to_watch,
:relative_paths => true,
:ignore => /logs\//) do |modified, added, removed|
# cheap way to add some separation between output from git commands
latest = Time.now
if (latest - last_change > 1)
last_change = latest
puts "\n\n"
end
modified.each{|m| puts "\e[33mCHANGED\e[0m #{m}" }
added.each{|m| puts "\e[32m ADDED\e[0m #{m}" }
removed.each{|m| puts "\e[31mREMOVED\e[0m #{m}" }
end
@schneems
Copy link

👍 thats cool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment