Interactive Command Customizer

Git & GitHub CLI Power Cheat Sheet

Customize variables live and copy ready-to-run Git & `gh` CLI commands for rebase, resets, stashing, and PR management.

Customize Command Variables

Undo last commit but keep changes staged

Undoes the last 3 commit(s) while retaining all your modifications in the staging area ready for re-committing.

git reset --soft HEAD~3

Hard reset local branch to remote origin

Discards all uncommitted local changes and aligns your current branch state exactly with origin/feature/auth-v2.

git reset --hard origin/feature/auth-v2

Modify last commit message or include newly staged files

Replaces the most recent commit with new staged changes and/or updated commit message.

git commit --amend -m "fix: resolve navigation state issue"

Unstage a single file without losing modifications

Removes the specified file from the staging index while keeping your edits on disk.

git restore --staged components/navbar/NavbarClient.js

Create and switch to new branch in one command

Creates a new branch and immediately checks it out for development.

git checkout -b feature/auth-v2

Delete all local branches already merged into main

Safely deletes local branches whose changes have already been merged into main.

git branch --merged main | grep -v '^*' | xargs -n 1 git branch -d

Interactive rebase to squash or edit past commits

Opens interactive terminal editor to reword, squash, or drop the last 3 commits.

git rebase -i HEAD~3

Stash specific file with a descriptive message

Stashes modifications to a single specified file instead of stashing all modified files.

git stash push -m "WIP work on components/navbar/NavbarClient.js" -- components/navbar/NavbarClient.js

Remove untracked files and directories dry-run

Performs a dry-run showing which untracked files and folders will be permanently deleted.

git clean -fdn

Compact one-line git log graph

Visualizes commit topology and branch merges in a clean one-line terminal format.

git log --graph --oneline --decorate --all

View safety log to recover lost commits (Reflog)

Shows a chronological log of all HEAD movements, allowing recovery of deleted commits or aborted rebases.

git reflog

Create Pull Request via GitHub CLI

Creates a pull request directly from terminal and opens the browser PR page.

gh pr create --title "fix: resolve navigation state issue" --body "Automated PR from feature/auth-v2" --web

Checkout PR by number to test locally

Downloads and switches to the remote branch of PR #42 for local testing.

gh pr checkout 42

Cite & Link This Resource

Backlink Magnet

Writing a blog post, GitHub README, or docs? Embed a backlink snippet or badge to cite this cheat sheet.

[Git & GitHub CLI Power Cheat Sheet](https://devdossier.com/resources/git-power-cheat-sheet) - Interactive Reference & Cheat Sheet via DevDossier
DevDossier Ecosystem20 Platforms

Find Us Everywhere

We publish, stream, and collaborate across every major developer & design platform. Follow along wherever you feel at home.

20+ Platforms
Global Presence
Developer First
Open Ecosystem
Daily Updates
Real-time Content
100% Free
Open Resources