gem install git-browse-remote
Just run git browse-remote on your GitHub-cloned repository.
This opens URL according to what branch you are on e.g.
Sometimes you will need to include revision SHA-1 in the URL for later reference. (ex. sharing an URL of an intensively developed branch on IRC)
Use --rev option to force revision-based page. 
git browse-remote --rev
will navigate you to the commit page (for example).
Use -- path and -L line to specify a file and a line number. 
git browse-remote -L1 -- .gitignore
will navigate you to the file at line 1 (for example).
To inspect a specific branch/commit, just pass it in the arguments.
git browse-remote refactor
will navigate you to the branch page (for example).
git browse-remote HEAD~1
will navigate you to the commit page (for example).
git browse-remote [-r|--remote <remote>] [--top|--rev|--ref] [-l <n>] [<commit-or-remote>] [--] [<file-or-directory>]
-r,--remote REMOTESpecifies remote (default: "origin"). Remote is used to decide the URL to open.
--topForces "top" mode (opens project top page).
--revForces "rev" mode (opens commit page).
--refForces "ref" mode (opens branch/tag page, may fail if none available).
-L LINESpecifies file line (only meaningful when FILE specified).
Specifies target commit (default: "HEAD"). Recognized as remote if equals to one of remotes.
Specifies a single file to view.
If none of --top, --rev, --ref is supplied, 
If you have GitHub-like repository browser, ex. GitHub Enterprise, at gh.example.com, set up by:
git browse-remote --init gh.example.com=github
Then you can open this non-github-com repository viewer. The settings are wrote to ~/.gitconfig.
For GitHub repositories, this initialization is not required.
If you want to write your own repository viewer's URL rules, these variables are available:
hostpathArray methods are available (e.g. path[-2,-1])refshort_refcommitshort_commitrevref or commitshort_revshort_ref or short_commitfilePathname methods are availablelineFor example, URL mappings for github.com are below by default:
[browse-remote "github.com"]
top = https://{host}/{path}
ref = https://{host}/{path}/tree/{short_ref}
rev = https://{host}/{path}/commit/{commit}
file = "https://{host}/{path}/{file.directory? and :tree or :blob}/{short_rev}/{file}{line && \"#L%d\" % line}"