Installation
The CLI is bundled with GitHub Desktop and available after installation:On Windows, you may need to add the GitHub Desktop installation directory to your PATH environment variable.
Usage
The CLI supports three main operations: opening repositories, cloning repositories, and getting help.Basic Syntax
Commands
Open Repository
Open the current directory or a specific path in GitHub Desktop:app/src/cli/main.ts
Clone Repository
Clone a repository by URL or owner/name format:1
Clone by URL
2
Clone by shorthand
owner/repo format to the full GitHub URL:app/src/cli/main.ts
3
Clone specific branch
app/src/cli/main.ts
Help
Display usage information:CLI Implementation
The CLI usesminimist for argument parsing and platform-specific launching:
app/src/cli/main.ts
Argument Parsing
The CLI supports these options:Platform-Specific Launching
The CLI spawns GitHub Desktop as a detached process, allowing the terminal session to continue independently.
Usage Examples
Open Current Repository
Open Specific Repository
Clone and Open
1
Clone from GitHub
2
Clone specific branch
3
Clone from URL
Workflow Integration
Integrate the CLI into shell scripts:Error Handling
The CLI includes comprehensive error handling:app/src/cli/main.ts
Help Output
app/src/cli/main.ts
Advanced Usage
Opening Recently Cloned Repository
After cloning a repository, GitHub Desktop automatically opens it:Path Resolution
The CLI resolves paths relative to the current working directory:app/src/cli/main.ts
Environment Variables
The CLI removes theELECTRON_RUN_AS_NODE environment variable to ensure proper launching:
app/src/cli/main.ts
Common Patterns
Quick Project Setup
Integration with Git Workflows
Troubleshooting
Command Not Found
1
Check installation
Verify GitHub Desktop is installed and the CLI is available:
2
Add to PATH (Windows)
On Windows, add the GitHub Desktop installation directory to your PATH:
3
Restart terminal
After installation or PATH changes, restart your terminal to pick up the new commands.
Repository Not Opening
If a repository doesn’t open:-
Verify the path exists:
-
Check it’s a Git repository:
- Check GitHub Desktop logs for error messages
Clone Fails
If cloning fails:- Verify repository exists: Check the URL or owner/repo format
- Check authentication: Ensure you’re logged into GitHub Desktop
- Network connectivity: Verify you can reach github.com
- Branch exists: If specifying a branch, ensure it exists in the repository