This repository is a command-line reference for working with GitHub using git and gh (GitHub CLI).
git config --global user.name "Your Name"
git config --global user.email "you@example.com"git clone https://github.com/user/repo.gitmkdir my-repo && cd my-repo
git init
gh repo create my-repo --public --source=. --remote=origin --pushgit checkout -b feature-branchgit push -u origin feature-branchgit pull origin maingit pull --rebase origin maingit add .
git commit -m "Your commit message"
git pushgit status
git log --oneline --graph --allgit reset HEAD~1 # Undo last commit, keep changes
git checkout . # Discard all unstaged changes
git clean -fd # Remove untracked files/foldersgit merge feature-branch
git rebase maingh pr create --base main --head feature-branch --title "PR title" --body "PR description"
gh pr view --web
gh pr checkout 123gh workflow list
gh run list
gh run watch <run-id>ssh-keygen -t ed25519 -C "you@example.com"
cat ~/.ssh/id_ed25519.pubAdd the key to GitHub β Settings β SSH and GPG keys
crontab -eAdd line to pull daily:
0 2 * * * cd /path/to/repo && git pull >> ~/git-sync.log 2>&1git submodule add https://github.com/user/lib.git lib
git submodule update --init --recursivegh release create v1.0.0 ./build.zip --title "Release v1.0.0" --notes "First stable release"