How can I open the current GitHub branch on Web using Windows command line?



I had this command working on my Mac/Linux (Terminal) with OhMyZsh, but once I moved to Windows, I wasn’t sure how to update it using Cmdr/ConEmu shell.

Basically, I want an alias that is like “goweb” that will open my default browser to the current branch on GitHub. I’m fine assuming a particular repo. Maybe a later enhancement would pull that as well using, e.g., default remote or the like..


This answer hard-codes the repo URL and just appends the current branch. Add this to your user-aliases.cmd (if using cmdr) or wherever you can set aliases.

goweb=@echo off && for /f %i in ('git rev-parse --abbrev-ref HEAD') do start https://<pathToRepo>/tree/%i

Replace with the URL to your repo.

Once this is in there, you can just type goweb from your CLI and it should open it for ya. Saves a few clicks when you need to do something on your current branch on GH.

Answered By – Ambrose Little

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More