Hi, I am Zil-e-huma a student ambassador from Pakistan pursuing software engineering.
Using Git through the command line is a surefire way to supercharge our development speed and efficiency. Using GitHub CLI, we can bring GitHub features directly into our terminal, saving our time and decreasing the need to switch between different interfaces. Let's dive into the eight most used GitHub CLI commands that every developer should understand to make the most of their workflow.
Why Use GitHub CLI?
Through GitHub you can interact with your repositories in many ways—whether it's through the web interface, a heavy web editor with GitHub.dev, a full environment developed for coding Codespaces, integrations with other editors like VS Code or JetBrains, GitHub Desktop, and now also GitHub Mobile. But what if we could streamline your workflow, without using different interfaces for different tasks, and do everything from the command line? Here GitHub CLI Comes in. GitHub CLI enables us to perform GitHub-related tasks directly in the terminal, staying focused on our Workflow.
Getting Started with GitHub CLI
First, we have to install GitHub CLI. This can be downloaded for Windows, Mac, or Linux by following the instructions in the GitHub CLI documentation (GitHub CLI documentation - GitHub Docs) When installed, just open your terminal and type `gh` to confirm it's working properly. To check it’s version, use:
Before moving forward, authenticate with GitHub using:
Follow the prompts to log in with your GitHub credentials.
Top 8 GitHub CLI Commands for Developers
These commands are a go-to tools for efficient project management and collaboration.
- Create and Clone Repositories
Creating a new repository is fast and simple using GitHub CLI. Just go to your desired directory and run:
To clone an existing repository:
For example, to clone GitHub CLI repository itself:
Using `gh repo clone` makes the validation and configuration process easy, resulting in the cloning process being more streamlined than the traditional `git clone`.
- Manage Issues Efficiently
GitHub Cli offers to track and manage issues directly from your terminal.
To get the list of opened issues:
For creating a new issue
To view a specific issue:
To seek a swift update on issues relevant to you, use:
These commands assist you in managing tasks, tracking progress, and collaborating with team members all in one place i.e. command line.
- Handling Pull Requests Like a Pro
Working with pull requests is a extremely simple using GitHub CLI.
To open list of all pull requests:
For creating a new pull request:
If you want to review the pull request, then use
Finally ready to merge, use following command
Through this simplified and easy process, the cede can be reviewed and merged through one place i.e. terminal.
- Create and View Releases
Releases are required for distributing your software.
For creating new release:
Want to bire existing releases, use following command.
And inspect a specific release using:
Through this command one can package his project seamlessly, along with version notes and binaries.
- Monitor GitHub Actions
To automate developers’ development process, GitHub actions are present.
To view a workflows list:
To see the working of a certain workflow
Track workflow runs:
Manage your automation tasks just from the terminal, making testing and development process fast.
- Work with Labels
To decide when which issue has to be resolved, we organize and prioritize them using labels.
Get the list of labels with;
For creating a new label:
To edit an existing label:
The proper use of labels makes the project maintainable and organized.
- Check Your GitHub Status
Stay updated about your tasks and notifications by checking the status through following command:
This command summarizes your assigned issues, pull requests, and any notifications that need your attention.
- Expand with Extensions
The GitHub CLI is open-source, allowing for community-driven extensions.
To browse available extensions:
For installing an extension:
For any specific need, we have extensions that add required specific functionality. Resulting in GitHub CLI having extra powers.
What's Next?
These commands provide a glimpse into the capabilities of GitHub CLI. As you start using these tools in your workflow, you'll notice that your productivity and efficiency will improve. Spending less time while navigating between different screens and more time in coding.
And if you ever get stuck or need guidance, don't forget to use:
Happy coding!
Microsoft Learn modules for further learning
- Automate your workflow with GitHub Actions
- Build community-driven software projects on GitHub
- Collaborate with others with Markdown and GitHub Pages
- GitHub Foundations
- GitHub fundamentals - Administration basics and product features
- Learn how Microsoft supports secure software development as part of a cybersecurity solution
- Manage source control
- Manage the lifecycle of your projects on GitHub