Skip to content

Instantly share code, notes, and snippets.

@lucas-clemente
Created May 30, 2012 12:38
Show Gist options
  • Save lucas-clemente/2836006 to your computer and use it in GitHub Desktop.
Save lucas-clemente/2836006 to your computer and use it in GitHub Desktop.
Git Sync
#!/usr/bin/env ruby -wKU
require 'rainbow'
def exec_cmd(cmd, ignore_fail = false)
puts cmd.bright
if !system(cmd, :out => File.open(File::NULL, 'w'))
if ignore_fail
return 1
else
puts "Command failed, aborting.".color(:red)
exit 1
end
end
end
msg = (ARGV.length > 0) ? ARGV * ' ' : "Commit on #{Time.now}"
exec_cmd('git pull')
exec_cmd('git add .')
exec_cmd("git commit -am '#{msg}'", true)
exec_cmd("git push")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment