GitHub CLI and GitHub Desktop – Work Without the Browser
Imagine you are working on a banking application. You have completed a feature, created a branch, committed your changes and now need to push them to GitHub. You also need to create a pull request and review a teammate's changes.
You can perform these activities by opening GitHub in your browser. But what if you could manage most of this workflow directly from your terminal or a desktop application?
GitHub provides two useful tools for this: GitHub CLI and GitHub Desktop. Both help developers work with GitHub repositories without depending on the browser for every operation.
- What GitHub CLI and GitHub Desktop are.
- How they differ from Git and the GitHub website.
- How to authenticate and work with repositories.
- How to create branches, commits and pull requests.
- How to choose the right tool for your development workflow.
1. Why Do We Need GitHub CLI and GitHub Desktop?
Git is the version control system used to track changes in source code. GitHub is a platform that hosts Git repositories and provides collaboration features such as pull requests, issues, reviews and project management.
Developers commonly use the GitHub website for collaboration. However, repeatedly switching between the code editor, terminal and browser can interrupt the development workflow.
GitHub CLI and GitHub Desktop reduce this friction in different ways:
- GitHub CLI: Manage GitHub operations using terminal commands.
- GitHub Desktop: Manage Git repositories through a graphical desktop interface.
2. Understanding Git, GitHub CLI and GitHub Desktop
Git
Git is a distributed version control system. It tracks changes in files, maintains commit history and supports branching and merging. Git can work locally without an internet connection.
GitHub CLI
GitHub CLI, commonly called gh, is an official command-line tool for working with GitHub. It allows developers to manage pull requests, issues, repositories, releases, workflows and other GitHub features from a terminal.
GitHub Desktop
GitHub Desktop is a graphical application that makes Git workflows easier to understand and perform. Developers can view file changes, create commits, switch branches, resolve supported merge conflicts and push or pull changes using a visual interface.
| Tool | Primary responsibility | Interface |
|---|---|---|
| Git | Version control and local repository operations | Command line or integrated tools |
| GitHub CLI | GitHub operations and collaboration workflows | Terminal |
| GitHub Desktop | Visual Git repository management | Desktop GUI |
| GitHub Website | Repository hosting and browser-based collaboration | Web browser |
3. How These Tools Work Together
Both tools connect your local development environment with GitHub. Git manages the repository and its history. GitHub CLI or GitHub Desktop helps you perform repository and collaboration activities.
Diagram: Developers can choose either tool to manage GitHub workflows while Git handles local version control and repository synchronization.
4. Installing GitHub CLI
GitHub CLI is available for Windows, macOS and Linux. Follow the official installation instructions for your operating system.
Official installation guide: https://cli.github.com/
Verify the installation
After installation, open a terminal or command prompt and run:
Check GitHub CLI version
gh --version
Example output
gh version 2.x.x https://github.com/cli/cli/releases
The version number depends on the version installed on your machine.
5. Authenticate GitHub CLI
Before using GitHub CLI for account-related operations, authenticate it with your GitHub account.
Start authentication
gh auth login
The interactive process asks you to select details such as:
- GitHub.com or a supported GitHub Enterprise host.
- Preferred Git protocol, such as HTTPS or SSH.
- Authentication method.
- Browser-based authentication or another supported method.
Follow the instructions shown in your terminal. If browser authentication is selected, you may be asked to enter a one-time code on GitHub.
Verify authentication status
gh auth status
Example output
github.com ✓ Logged in to github.com account developer-name ✓ Git operations for github.com configured to use https ✓ Token: ************
6. Working with Repositories Using GitHub CLI
Let's use an employee management application as an example. Assume your team has a repository named employee-management.
6.1 Clone a repository
To download a repository to your local machine, use:
gh repo clone organization/employee-management
This command clones the repository and creates a local working directory.
6.2 View repository details
gh repo view organization/employee-management
This displays repository information such as its description, visibility and other available details.
6.3 Create a new branch
Move into the cloned repository and create a feature branch using Git:
cd employee-management
git switch -c feature/employee-search
The branch keeps your feature changes separate from the main development line.
6.4 Commit and push changes
After modifying the application, stage and commit your files:
git status
git add .
git commit -m "Add employee search feature"
git push -u origin feature/employee-search
Here, Git performs the local version-control operations and pushes the branch to the remote repository.
7. Creating and Managing Pull Requests Using GitHub CLI
One of the most useful features of GitHub CLI is managing pull requests directly from the terminal.
7.1 Create a pull request
Once your branch is pushed, create a pull request:
gh pr create \
--base main \
--head feature/employee-search \
--title "Add employee search feature" \
--body "Adds employee search functionality."
This creates a pull request targeting the main branch from your feature branch. Repository rules and permissions still apply.
7.2 List pull requests
gh pr list
7.3 View a pull request
gh pr view 42
7.4 Check out a pull request locally
gh pr checkout 42
7.5 Review and merge a pull request
You can inspect changes and submit a review from the command line:
gh pr diff 42
gh pr review 42 --approve
When you are authorised and the repository's required checks and review policies are satisfied, you can merge:
gh pr merge 42 --squash
8. Useful GitHub CLI Commands
| Command | Purpose |
|---|---|
gh auth login |
Authenticate with GitHub. |
gh auth status |
Check authentication status. |
gh repo clone |
Clone a GitHub repository. |
gh repo create |
Create a repository. |
gh repo view |
View repository details. |
gh pr create |
Create a pull request. |
gh pr list |
List pull requests. |
gh pr checkout |
Check out a pull request branch. |
gh pr diff |
View pull request changes. |
gh issue list |
List repository issues. |
gh workflow list |
List GitHub Actions workflows. |
9. Installing GitHub Desktop
GitHub Desktop is useful for developers who prefer a graphical interface for common Git operations.
Download it from the official website:
After installation:
- Open GitHub Desktop.
- Sign in using your GitHub account.
- Authorise the application when prompted.
- Choose an existing repository to add, or clone a repository from GitHub.
10. Working with GitHub Desktop
Let's perform the same employee management workflow using GitHub Desktop.
10.1 Clone a repository
- Open GitHub Desktop.
- Select File → Clone Repository.
- Choose the repository from your GitHub account or enter its URL.
- Select a local path.
- Click Clone.
10.2 View changed files
When you modify files in your code editor, GitHub Desktop detects the changes automatically. The Changes tab displays modified, added and deleted files.
You can select individual files to inspect their differences. Added and removed lines are highlighted, helping you understand exactly what will be included in the commit.
10.3 Create a branch
- Open the Current Branch menu.
- Select New Branch.
- Enter
feature/employee-search. - Choose the base branch.
- Create the branch.
10.4 Commit changes
Enter a meaningful summary, such as Add employee search feature, and optionally provide a longer description.
Click Commit to feature/employee-search. GitHub Desktop creates the local Git commit.
10.5 Push changes
After committing, click Push origin to publish your local branch and commits to the remote repository.
10.6 Create a pull request
Once the branch is published, use the option to preview or create a pull request. GitHub Desktop opens the pull request workflow in GitHub, where you can confirm the title, description, base branch and reviewers.
11. GitHub CLI vs GitHub Desktop
| Capability | GitHub CLI | GitHub Desktop |
|---|---|---|
| Interface | Terminal | Graphical interface |
| Learning curve | Requires command knowledge | Visual and approachable |
| Branch management | Git commands | Visual branch controls |
| Commit management | Git commands | Visual changes and commit interface |
| Pull requests | Create, inspect, review and merge through commands | Can open and create PR workflows with GitHub |
| Automation | Easy to script and integrate | Primarily interactive |
| Best suited for | Terminal users and automation | Developers who prefer visual workflows |
12. Can We Use Both Tools Together?
Yes. GitHub CLI and GitHub Desktop can work with the same local Git repository. You do not need to choose only one.
For example, a developer might use GitHub Desktop to inspect file changes and create commits, then use GitHub CLI to list pull requests, check out a teammate's branch or inspect GitHub Actions workflows.
Diagram: Both tools can access the same local repository. Changes made by one tool are reflected in the repository seen by the other.
13. Common Mistakes and Best Practices
Common mistakes
- Assuming GitHub CLI replaces Git: GitHub CLI handles GitHub features; Git still performs core version-control operations.
- Working on the wrong branch: Check the current branch before editing or committing.
- Forgetting to push: A local commit is not automatically available to your teammates.
- Sharing authentication tokens: Treat tokens as credentials and never expose them.
- Ignoring file differences: Review staged or changed files before creating a commit.
- Assuming a pull request is automatically approved: Follow required reviews and status checks.
Recommended practices
- Use meaningful branch names such as
feature/employee-searchandbugfix/login-validation. - Write clear commit messages that explain the change.
- Keep commits focused on related changes.
- Review the diff before committing or opening a pull request.
- Use GitHub CLI for repeatable workflows and automation.
- Use GitHub Desktop when visual inspection makes the work easier.
- Follow your organisation's branch protection and security policies.
14. Real-World Development Workflow
Consider a team developing an employee management platform. A developer is assigned the employee search feature.
Clone the repository or update your local copy using GitHub Desktop or Git commands.
Create feature/employee-search from the agreed base branch.
Make the required changes in your IDE and run the relevant tests locally.
Review the changes, create a commit and push the feature branch.
Use gh pr create or GitHub Desktop to start the pull request process.
Address review comments, satisfy required checks and merge according to the team's policy.
15. Interview Questions and Answers
1. What is GitHub CLI?
GitHub CLI is an official command-line tool that allows developers to interact with GitHub from a terminal. It supports operations such as repository management, pull requests, issues and GitHub Actions workflows.
2. What is the difference between Git and GitHub CLI?
Git is a distributed version control system used to track source-code changes and manage repository history. GitHub CLI is a tool for interacting with GitHub features, such as pull requests, issues and remote repositories.
3. Can GitHub CLI create a pull request?
Yes. The gh pr create command can create a pull request from a local branch that has been published to the remote repository.
4. What is the main advantage of GitHub Desktop?
It provides a graphical interface for common Git operations. Developers can inspect file differences, create commits, manage branches and synchronize changes without remembering every Git command.
5. Can GitHub CLI and GitHub Desktop work on the same repository?
Yes. Both can work with the same local Git repository. Changes made through either tool are reflected in that repository. Developers should be careful about simultaneous changes and always review the working-tree status.
16. Hands-On Practice
Try the following exercises to understand both tools through practical usage.
- Install GitHub CLI and GitHub Desktop on your machine.
- Authenticate with your GitHub account using both applications.
- Clone an existing repository using GitHub CLI.
- Open the same local repository in GitHub Desktop.
- Create a branch named
feature/readme-update. - Modify the README file and inspect the changes in GitHub Desktop.
- Commit and push the changes.
- Create a pull request using
gh pr create. - View the pull request using
gh pr view.
17. Official Documentation and Learning Resources
- GitHub CLI – Official Website
- GitHub CLI – Command Manual
- GitHub CLI – GitHub Documentation
- GitHub Desktop – Official Website
- GitHub Desktop – Documentation
- Git – Official Documentation
Conclusion
GitHub CLI and GitHub Desktop make everyday GitHub workflows more convenient. GitHub CLI is particularly useful for developers who prefer the terminal, want to automate repetitive tasks or integrate GitHub operations into scripts. GitHub Desktop is useful when a visual interface makes it easier to inspect changes and manage repositories.
Both tools work with Git rather than replacing it. Understanding Git fundamentals first, and then learning these tools, helps developers work more confidently in individual and team projects.
Learn Technology. Build Your Future.
Upgradix by Shrash Studio