GitHub Commands Cheat Sheet 2025 | Ultimate Developer Reference Guide

All essential commands for developers - Bookmark or print for quick reference

📅 Updated: 🔖 Difficulty: Beginner to Advanced

📦 Repository Basics

git init

Initialize new repository

git clone [url]

Clone existing repository

git remote add origin [url]

Connect local to remote

git remote -v

View connected remotes

git remote remove [name]

Remove a remote

git fetch

Download objects from remote

🌿 Branching

git branch

List all branches

git branch -a

List all branches (including remote)

git checkout -b [branch]

Create & switch branch

git checkout [branch]

Switch to branch

git merge [branch]

Merge branches

git branch -d [branch]

Delete local branch

git push origin --delete [branch]

Delete remote branch

💾 Commits

git add [file]

Stage specific file

git add .

Stage all changes

git commit -m "message"

Commit with message

git commit --amend

Modify last commit

git commit --amend --no-edit

Amend without changing message

git reset HEAD~1

Undo last commit (keep changes)

👥 Collaboration

git push origin [branch]

Push to remote

git push -u origin [branch]

Push and set upstream

git pull

Fetch + merge changes

git pull --rebase

Pull with rebase instead of merge

git stash

Temporarily save changes

git stash pop

Restore stashed changes

git cherry-pick [commit]

Apply specific commit

⏪ Undoing

git reset [file]

Unstage file

git checkout -- [file]

Discard changes

git revert [commit]

Reverse a commit

git reset --hard HEAD

Discard all local changes

git reset --hard [commit]

Reset to specific commit (DANGEROUS)

git clean -fd

Remove untracked files/dirs

🔍 Inspection

git status

Show working tree status

git log --oneline

Compact history

git log --graph --all

Visual history with branches

git diff

Show unstaged changes

git diff --staged

Show staged changes

git blame [file]

See line-by-line changes

git show [commit]

Show changes in commit

🛠️ GitHub CLI

gh repo create

Create new repository

gh pr create

Create pull request

gh issue create

Create new issue

gh repo clone [owner/repo]

Clone repository

gh pr checkout [number]

Checkout pull request

⚡ Advanced

git rebase [branch]

Reapply commits on top of branch

git rebase -i HEAD~3

Interactive rebase (last 3 commits)

git bisect start

Find commit that introduced bug

git filter-branch

Rewrite branch history (DANGEROUS)

git reflog

Show reference logs (for recovery)


Post a Comment

0 Comments

Top Post Ad

Bottom Post Ad