banner



How to use the GitHub CLI app on Windows and WSL

Github Source: Windows Central

Microsoft-owned GitHub is the biggest code-sharing platform on the planet and while using information technology through the web browser is simple, when you're interacting with your code and local files you lot're more than likely using a concluding.

That'southward where GitHub CLI comes in. An official tool fabricated by GitHub, it'southward good to apply both on Windows 10 and Windows eleven in PowerShell or within the Windows Subsystem for Linux (WSL). Once you're familiar with information technology, it could speed up a number of areas of your GitHub workflow.

Hither's how to install it, get set upwardly and comport out some bones processes.

Prepare upward a GitHub account before annihilation else

Github Homepage Source: GitHub

You don't need a GitHub account to scan code and clone repos, but it'due south yet worth signing upwardly. Simply with your own business relationship and repo infinite can you store your ain files and fork other projects, follow other members, and star repos for easy access subsequently. It'southward completely free to use and doesn't require you to take a Microsoft Account.

A GitHub account besides allows you lot to make utilise of the oft-overlooked GitHub CLI last application, which due to some changes in how GitHub allows accounts to exist authenticated, is really something you should take. More on that later.

Yous don't take to interact with GitHub through the terminal, only in many cases, it's the most efficient workflow.

Installing GitHub CLI onto Windows or WSL

Github Cli Repo Source: Windows Central

The GitHub CLI tool is an official GitHub application, and if you're going to be using GitHub, it's well worth having. For one, it gets effectually using personal access tokens with Git to push local repositories up to GitHub, as you lot can apply the GitHub CLI application to authenticate your whole system.

To install the GitHub CLI on Windows you can use the Windows Package Managing director once again by entering winget install github.cli, or catch information technology directly from GitHub. Alternatively, it's bachelor through the Scoop and Chocolately package managers, also, where you'll simply need to install gh.

On WSL, the process is a lilliputian more involved, only GitHub has full documentation you can follow. Since virtually people using WSL are likely to have Ubuntu or Debian installed every bit they're officially distributed through the Microsoft Shop, y'all can utilize the following commands in your WSL concluding to install it.

            coil -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg echo "deb [arch=$(dpkg --print-architecture) signed-past=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable principal" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/zero sudo apt update sudo apt install gh                      

Every bit with Git, the WSL installation of the GitHub CLI is split from the Windows installation y'all would use in PowerShell. The two operate the aforementioned way, but if you switch between WSL and PowerShell you lot'll need to have information technology installed in both locations.

How to gear up up GitHub CLI and authenticate your account

The GitHub CLI, unlike Git, can use your account login and countersign for authentication with the added bonus of then as well allowing Git to push to your GitHub repositories. To cosign GitHub CLI, open your terminal and follow these steps. Again, all the steps are the same whether yous utilise Windows or WSL.

  1. In the terminal enter gh auth login
  2. Choose GitHub.com.
  3. Select HTTPS as the protocol.

    Github Cli Login Source: Windows Central

  4. Type Y to cosign with your GitHub credentials
  5. Hit Enter to login with a web browser.

    Github Auth Source: Windows Cardinal

  6. Note down the 1-fourth dimension code you're presented with, and printing Enter.
  7. A browser will now open, and you lot'll demand to log into GitHub if you aren't already.
  8. Enter the ane-fourth dimension code in the box.

You'll now be logged into the GitHub CLI client. To come across the full listing of commands available simply blazon gh --aid into the last.

Using GitHub CLI

At that place is a basic command template for using GitHub CLI that looks like this:

            gh [command] [sub-command] [flags]                      

All commands you lot enter will brainstorm with gh in order to trigger GitHub CLI. At that place are a number of commands to use, but here are some examples of how you lot would carry out some bones functions.

Create a new GitHub repository

Github Cli Repo Create Source: Windows Central

GitHub CLI gives y'all the power to create a new remote repository without having to beginning become to the GitHub website and then link it back to your local car. To exercise so you demand to have Git initialized in your local directory then navigate at that place in the last. Then enter:

            gh repo create                      

You'll be asked to give information technology a proper name, an optional clarification, its visibility and to ostend yous want to create an "origin" Git remote in your local directory. Once all are completed, you can go check out your new repo on the GitHub website. You can open up this or any of your other GitHub repos from their local directories past entering gh browse into the terminal.

Clone or fork a GitHub repository

Github Cli Repo Clone Source: Windows Central

Well-nigh of the time you'll use the git clone command to clone a local re-create of a GitHub repository, but y'all can practise the same using the GitHub CLI tool using this control.

            gh repo clone [user/repo proper name or URL]                      

So for case, to clone Microsoft Visual Studio yous would merely enter:

            gh repo clone microsoft/vscode                      

Github Cli Repo Clone Source: Windows Primal

The end result is the same as using Git, and a new directory will be created on your local machine with all contents of the remote repository independent within. You tin can also use GitHub CLI to clone repos with the full URL if y'all have that instead, and using the same command without the username will let you to clone your own repos easily.

            gh repo clone [your repo proper noun]                      

Github Cli Repo Fork Source: Windows Central

You tin besides use GitHub CLI to fork a repository and clone a local copy if y'all wish. You don't accept to clone it, however, but information technology'due south a quick way to attain both goals with one control.

            gh repo fork [user/repo proper name or URL]                      

For instance:

            gh repo fork microsoft/winget-pkgs                      

Once you hit Enter, you'll be asked whether you want to clone the fork or not, with a simple y or n being all you lot demand to enter.

Github Cli Repo List Source: Windows Primal

The GitHub CLI tool also has an like shooting fish in a barrel way to notice repos you might desire to clone, bold you know the organisation or username. For example, to encounter all Microsoft repositories on GitHub yous might enter:

            gh repo list microsoft                      

Creating a new issue

Github Cli Issue Create Source: Windows Central

Creating bug is a cardinal part of the GitHub process, and you can do that right from the command line using this command.

            gh outcome create                      

The tool will then inquire you to give your outcome a championship, followed by opening a text editor, such equally Nano in WSL, to fill out the trunk of the effect, so the option to submit or to keep in the browser. Information technology's actually straightforward, and the prompts will guide you at every step.

Viewing and closing issues

Github Cli Issue List Source: Windows Central

To get a full listing of the available tools for the consequence command type gh issue --help into the terminal. One of the most common y'all'll want to use is viewing issues so closing them if dealt with.

To view all issues for your GitHub repository enter this command.

            gh issue list                      

Github Cli Issue Close Source: Windows Fundamental

Yous'll now be given a printout of all bug submitted to that repository. To close off issues that have been dealt with, take note of the issue number and enter this command.

            gh issue close 1                      

You'll exist given a confirmation that the issue has closed, and to confirm you tin run the list command once again, and it should be gone.

Creating a pull request

Github Cli Pr Source: Windows Central

There are a number of options you take when creating pull requests in GitHub CLI, just the basic template is equally follows.

            gh pr create [subcommand]                      

At any time you tin add --help to the above to get a total breakdown of all available options. If y'all wanted to create a pull request and go on it on the web, for instance, you would enter:

            gh pr create -due west                      

Pull requests carry in exactly the aforementioned way as on the web, and so naturally won't work if you lot're on the master branch.

There's a lot more to GitHub CLI than nosotros've talked about here, simply hopefully, this gets yous pointing in the right direction, particularly if yous're a beginner to using GitHub at all. Nosotros have a total beginner'south guide to GitHub that'southward a skillful companion to this, but once you're comfortable with the basics there's a lot to explore. Well-nigh of GitHub'due south master features can be interacted with using the CLI tool.

If at whatever point you need a chip more information, the --help flag subsequently a command is your friend, equally it'll pause down everything yous can do with every possible command available in GitHub CLI.

Source: https://www.windowscentral.com/how-use-github-cli-app-windows-and-wsl

Posted by: hatcherdeconsenry.blogspot.com

0 Response to "How to use the GitHub CLI app on Windows and WSL"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel