gh browse: Open a GitHub repository in the browser or print the URL

“gh browse” is a command provided by GitHub CLI (Command-Line Interface) that allows users to conveniently open a GitHub repository in their web browser or retrieve the URL of the repository. This command simplifies the process of accessing and exploring GitHub repositories by providing a seamless integration between the command-line interface and the browser.

With “gh browse,” users can quickly open a repository’s web page in their default browser by simply executing the command. This allows them to view the repository’s code, issues, pull requests, and other relevant information directly in the browser interface.

Here are the key features and functionalities of “gh browse”:

  • Web Browser Integration: “gh browse” seamlessly integrates with the user’s default web browser. This means that executing the command automatically opens the GitHub repository page in a new tab or window of the browser, providing a smooth transition from the command-line interface to the graphical interface.
  • Convenient Repository Access: The command allows users to access a repository’s web page with a single command, eliminating the need to manually navigate to the repository in the browser. This saves time and provides a more efficient way to explore and interact with repositories.
  • URL Retrieval: In addition to opening the repository in the browser, “gh browse” can also print the URL of the repository to the command-line interface. This is useful if users prefer to manually copy and paste the URL for later use or to share it with others.
  • GitHub Enterprise Support: “gh browse” supports both GitHub.com repositories as well as self-hosted GitHub Enterprise repositories. Users can seamlessly open and access repositories from their GitHub Enterprise Server instance in the same way as with GitHub.com repositories.

By using “gh browse,” users can effortlessly transition between the command-line interface and the web browser, enabling them to quickly explore and interact with GitHub repositories. It provides a convenient way to view code, track issues, collaborate on pull requests, and access other repository features without the need for manual navigation in the browser.

gh browse Command Examples

1. Open the homepage of the current repository in the default web browser:

# gh browse

2. Open the homepage of a specific repository in the default web browser:

# gh browse owner/repository

3. Open the settings page of the current repository in the default web browser:

# gh browse --settings

4. Open the wiki of the current repository in the default web browser:

# gh browse --wiki

5. Open a specific issue or pull request in the web browser:

# gh browse issue_or_pull_request_number

6. Open a specific branch in the web browser:

# gh browse --branch branch_name

7. Open a specific file or directory of the current repository in the web browser:

# gh browse path_from_root_of_repository

8. Print the destination URL without open the web browser:

# gh browse --no-browser

Summary

Overall, “gh browse” enhances the usability of GitHub CLI by integrating the command-line interface with the web browser. It offers a seamless and efficient method to open GitHub repositories in the browser or retrieve their URLs, enabling users to effortlessly navigate and interact with repositories in their preferred graphical interface.

Related Post