2026-03-15

Open a GitHub Repository in the Browser from the Terminal

Notes
This article was translated by GPT-5.4. The original is here.

TL;DR

With GitHub CLI, you can open the URL of the current GitHub repository with this command:

Open a GitHub repository URL from the terminal

When working in the terminal, there are times when you want to open a GitHub URL immediately. In that case, if the repository is on GitHub, you can use the gh command (GitHub CLI) to open the URL directly in your browser.

This works as long as a remote repository is configured. If you use GitHub as the remote repository, you have probably either run the following command when creating the repository,

or you created the repository on GitHub first and then cloned it locally, so it should already be set up. You can check whether a remote repository is configured with this command:

Why I wrote this article

I remembered that I could open a GitHub repository with the gh command, but I forgot which subcommand it was. So I searched with some likely keywords, but the simplest solution did not show up at the top.

Other methods besides gh browse that show up include:

  • a git alias
  • a bash/zsh alias
  • hub browse from the hub command
  • gh repo view --web using the repo subcommand of gh

Maybe gh repo view --web used to be the only way, but now gh browse can open not only repositories but many kinds of GitHub pages directly from the terminal.

That is why I wanted to leave this note for anyone searching for how to open GitHub from the terminal.

gh browse

【改訂新版】Gitポケットリファレンス

【改訂新版】Gitポケットリファレンス

Amazon アソシエイトについて

この記事には Amazon アソシエイトのリンクが含まれています。Amazonのアソシエイトとして、SuzumiyaAoba は適格販売により収入を得ています。