When you push a new branch to GitHub from the command line, you’ll notice a URL within the output which you can copy in order to quickly open a new pull request.
But if you are on old branch…then nothing will help you.
And I was tired opening the github website so…. here it is a small ruby script which opens my browser at the correct place in github.
#!/usr/bin/env ruby output = `git branch` selected_branch = output.split("\n").find{|element| element =~ /^\*/} current_branch = selected_branch.split(' ').last remote = `git remote -v`.split("\n").find{|element| element =~ /origin\s.*?push\)$/}.split(' ')[1] githost = remote.gsub('git@', '').gsub(/.git$/, '').gsub(/^github.com:/, 'github.com/') `chromium-browser https://#{githost}/compare/#{current_branch}?expand=1`
Update: This version supports sub-modules
Open current github repository in Browser
Script to open the current github repo in the browser
#!/usr/bin/env ruby
output = `git branch`
selected_branch = output.split("\n").find{|element| element =~ /^\*/}
current_branch = selected_branch.split(' ').last
remote = `git remote -v`.split("\n").find{|element| element =~ /origin\s.*?push\)$/}.split(' ')[1]
githost = remote.gsub('git@', '').gsub(/.git$/, '').gsub(/^github.com:/, 'github.com/')
`chromium-browser https://#{githost}/`
Track the current branch
The cure is the next script
#!/usr/bin/env ruby
output = `git branch`
selected_branch = output.split("\n").find{|element| element =~ /^\*/}
current_branch = selected_branch.split(' ').last
origin = `git remote -v`.split("\n").find{|element| element =~ /origin\s.*?push\)$/}.split(' ')[0]
`git branch --set-upstream-to=#{origin}/#{current_branch} #{current_branch}`