Mastering GitHub with the GitHub CLI

AlexLearn Supplement · Hands-On Reference for Every Participant

A practical guide to installing the GitHub CLI, creating repositories, and maintaining your projects — no browser required.


Why GitHub?

GitHub is where your Alex-powered work lives. It is the version control layer that:


1 · Install the GitHub CLI

The GitHub CLI (gh) lets you create repos, open pull requests, manage secrets, and trigger workflows — all from your terminal.

Windows

# Option A — winget (built into Windows 11)
winget install --id GitHub.cli

# Option B — Scoop
scoop install gh

# Option C — download the MSI installer
# https://github.com/cli/cli/releases/latest

macOS

# Homebrew
brew install gh

Linux (Debian / Ubuntu)

(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
&& wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg \
   | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
   | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update && sudo apt install gh -y

Verify the installation

gh --version
# gh version 2.x.x (...)

2 · Authenticate

Log in once — gh stores a token securely in your system keychain.

gh auth login

Follow the prompts:

  1. Choose GitHub.com
  2. Choose HTTPS as your preferred protocol
  3. Choose Login with a web browser and paste the one-time code when prompted

Verify you are logged in:

gh auth status
# ✓ Logged in to github.com account your-username

3 · Create a Repository

From an existing local folder

This is the most common case — you have work on your laptop and want it on GitHub.

# Navigate to your project folder
cd ~/my-project

# Initialize git if it isn't already
git init
git add -A
git commit -m "initial commit"

# Create the remote and push in one step
gh repo create my-project \
  --public \
  --description "My Alex-powered project" \
  --push \
  --source .

--public makes the repo visible to everyone. Use --private for private repos.

From scratch (empty repo)

gh repo create my-new-project --public --clone
cd my-new-project

Fork an existing repo

gh repo fork fabioc-aloha/AlexLearn --clone

4 · Clone a Repository

# Clone by name (your own repo)
gh repo clone my-project

# Clone someone else's repo
gh repo clone fabioc-aloha/AlexLearn

# Classic git clone also works
git clone https://github.com/username/repo-name.git

5 · The Daily Git Workflow

These four commands cover 90% of everyday version control.

# 1. Pull the latest changes before you start
git pull

# 2. Make your changes, then stage them
git add -A               # stage everything
git add src/file.ts      # or stage one file

# 3. Commit with a message
git commit -m "feat: add persona selector to homepage"

# 4. Push to GitHub
git push

Commit message conventions

PrefixWhen to use
feat:New feature or content
fix:Bug fix or correction
docs:Documentation only
ci:Workflow / pipeline changes
chore:Maintenance, dependencies
refactor:Code restructuring, no behavior change

6 · Branching

Work on a branch to keep main stable.

# Create and switch to a new branch
git checkout -b feature/new-workshop-content

# Push the branch
git push -u origin feature/new-workshop-content

# Open a pull request from the CLI
gh pr create \
  --title "Add engineers workshop content" \
  --body "Adds STUDY-GUIDE and TALKING-POINTS for the engineers persona"

# Merge via CLI once approved
gh pr merge --squash

7 · Managing Your Repository

View status and history

git status                 # what has changed
git log --oneline -10      # last 10 commits
git diff                   # what changed in unstaged files

Repository information

gh repo view               # view your current repo in the terminal
gh repo view --web         # open it in the browser

Releases

# Create a release tag
gh release create v1.0.0 \
  --title "AlexLearn v1.0 — Workshop Launch" \
  --generate-notes

Secrets (for CI/CD)

# Add a secret (e.g. Azure deploy token)
gh secret set MY_SECRET --body "secret-value"

# List secrets (names only — values are never shown)
gh secret list

8 · Useful Shortcuts

# Open the repo in the browser
gh browse

# View recent workflow runs
gh run list

# Watch a running workflow
gh run watch

# View issues
gh issue list

# Create an issue
gh issue create --title "Bug: broken link on homepage" --body "..."

9 · Setting Up Alex in a New Repo

After you create a repo and clone it, initialize Alex:

  1. Open the folder in VS Code
  2. Open GitHub Copilot Chat
  3. Type: Alex: Initialize Architecture

Alex will scaffold the full .github/ cognitive architecture into your repo. Commit and push:

git add -A
git commit -m "feat: initialize Alex cognitive architecture"
git push

10 · .gitignore Essentials

A .gitignore file tells git which files never to track. Create one in any project root:

# Dependencies
node_modules/
__pycache__/
.venv/

# Build output
dist/
build/
out/

# Environment secrets
.env
.env.local
*.key

# OS noise
.DS_Store
Thumbs.db

# IDE
.vscode/settings.json   # optional — many teams DO commit this
*.vsix

Generate one for your stack at gitignore.io.


Quick Reference Card

TaskCommand
Log ingh auth login
Create repo from foldergh repo create <name> --push --source .
Clone a repogh repo clone <owner/repo>
Stage all changesgit add -A
Commitgit commit -m "message"
Pushgit push
Pullgit pull
New branchgit checkout -b branch-name
Open PRgh pr create
View repo in browsergh repo view --web
Add CI secretgh secret set NAME --body "value"
Run listgh run list

AlexLearn · Created by Fabio Correa · correax.com