David Galiata's tech blog

Creating GitHub Repositories from CLI

Black and blue square illustration
Published on
/2 mins read

Picture this: You've just built a small app and want to share it with the world. Let's learn how to create a GitHub repository straight from your terminal.

Prerequisites

# Install GitHub CLI
# macOS
brew install gh
 
# Windows
winget install GitHub.cli

Quick Setup

Navigate to your project:

cd ~/projects/weather-dashboard

Initialize Git:

git init
git add .
git commit -m "First forecast: Initial commit"

Authenticate with GitHub:

gh auth login

Create and push your repository:

gh repo create weather-wizard --public --source=. --push

Command Breakdown

Let's analyze that last command:

  • weather-wizard: Repository name
  • --public: Makes it visible to everyone
  • --source=.: Uses current directory
  • --push: Uploads files automatically

Advanced Options

Add metadata:

gh repo create climate-tracker \
  --description "Real-time weather monitoring dashboard" \
  --homepage "https://weather-app.example.com" \
  --public --source=. --push

Create with license:

gh repo create forecast-pro --license "mit" --public --source=. --push

Troubleshooting

Common issues:

  • Repository names must use hyphens instead of spaces
  • For private repos, swap --public with --private
  • Conflicts? Use --remote-name origin

Final Thoughts

GitHub CLI transforms repository creation into a streamlined process. No more context switching between terminal and browser - just efficient, focused development.


Written for folks who value their time