Skip to content

Latest commit

Β 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 

Repository files navigation

🧾 GitHub CLI Cheatsheet

This repository is a command-line reference for working with GitHub using git and gh (GitHub CLI).


πŸ”§ Git Setup

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

πŸ“ Repository Operations

Clone a repo

git clone https://github.com/user/repo.git

Create a new repo (local + remote)

mkdir my-repo && cd my-repo
git init
gh repo create my-repo --public --source=. --remote=origin --push

🌿 Branching

Create and switch to a branch

git checkout -b feature-branch

Push branch to GitHub

git push -u origin feature-branch

πŸ”„ Syncing

Pull latest changes

git pull origin main

Rebase current branch

git pull --rebase origin main

βœ… Staging & Committing

git add .
git commit -m "Your commit message"
git push

πŸ” Status & Log

git status
git log --oneline --graph --all

πŸ” Undo

git reset HEAD~1       # Undo last commit, keep changes
git checkout .         # Discard all unstaged changes
git clean -fd          # Remove untracked files/folders

πŸ”€ Merging & Rebasing

git merge feature-branch
git rebase main

πŸš€ Pull Requests (via gh)

gh pr create --base main --head feature-branch --title "PR title" --body "PR description"
gh pr view --web
gh pr checkout 123

πŸ§ͺ GitHub Actions

gh workflow list
gh run list
gh run watch <run-id>

πŸ”’ SSH Setup

ssh-keygen -t ed25519 -C "you@example.com"
cat ~/.ssh/id_ed25519.pub

Add the key to GitHub β†’ Settings β†’ SSH and GPG keys


πŸ•’ Cron Example for Repo Backup (Linux/macOS)

crontab -e

Add line to pull daily:

0 2 * * * cd /path/to/repo && git pull >> ~/git-sync.log 2>&1

πŸ“¦ Submodules

git submodule add https://github.com/user/lib.git lib
git submodule update --init --recursive

πŸ“€ GitHub Release (via gh)

gh release create v1.0.0 ./build.zip --title "Release v1.0.0" --notes "First stable release"

πŸ“š Resources


✍️ Author: \ Jamaurice Holt

About

This repository is a command-line reference for working with **GitHub** using `git` and `gh` (GitHub CLI).

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors