Skip to content

Instantly share code, notes, and snippets.

@lkosak
Created July 18, 2013 17:45
Show Gist options
  • Save lkosak/6031354 to your computer and use it in GitHub Desktop.
Save lkosak/6031354 to your computer and use it in GitHub Desktop.
Drop this in ~/.git/hooks/pre-push and run chmod +x ~/.git/hooks/pre-pus!
#!/usr/bin/env ruby
local, remote = ARGV[0], ARGV[1]
address = remote.match(/git@(?<host>.*?):(?<account>.*?)\/(?<repo>.*?).git/)
branch = `git symbolic-ref HEAD`.strip.split('/').last
if(address[:host] == 'github.com' and branch != 'master')
puts "Pushing to http://github.com/#{address[:account]}/#{address[:repo]}/tree/#{branch}"
end
@jimmytang
Copy link

I'm getting an error

jimmy@Jimmys-MacBook-Pro:~/Code/airbnb|phone_messaging_7⚡ ⇒ git push origin phone_messaging_7

.git/hooks/pre-push:4: undefined (?...) sequence: /git@(?.?):(?.?)/(?.*?).git/

error: failed to push some refs to 'git@github.com:airbnb/airbnb.git'

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