Skip to main content
Developer Tools

Git & GitHub CLI

Essential

Essential Git commands, branch operations, interactive rebasing, stashing, and commit history manipulation.

Instant Copy & SearchProduction Flagged SyntaxCurrent Flag Reference

Git & GitHub CLI Interactive Command Directory

Browse, search, and copy battle-tested commands & syntax recipes (19 Total Commands).

19+ Verified Recipes
Status & Inspection-sb
git status -sb

Show working tree status in short format with branch tracking info.

Branching & Switching-c <branch>
git switch -c feature/auth

Create and immediately switch to a new local feature branch.

Committing-m <msg>
git commit -m "feat: implement OAuth2 refresh token rotation"

Record staged changes to repository history with a conventional commit message.

History & Logs--oneline, --graph, --decorate
git log --oneline --graph --decorate --all -n 15

Display visual ASCII branch history with commit hashes, tags, and head pointers.

Interactive Rebasing-i
git rebase -i HEAD~5

Interactively squash, reword, drop, or reorder the last 5 commits on current branch.

Stashingpush -m <label>
git stash push -m "wip-payment-integration"

Temporarily shelf modified and staged changes with a descriptive label.

Stashingpop
git stash pop

Reapply the most recently stashed changes and remove them from the stash list.

Undoing & Reset--soft
git reset --soft HEAD~1

Undo the latest commit while preserving all changes staged in the index.

Cherry-Picking<hash>
git cherry-pick <commit-hash>

Apply the exact changes introduced by a specific commit from another branch.

Diffing--staged
git diff --staged

View precise character-level diffs staged for the next commit.

Unstaging--staged
git restore --staged <file>

Unstage a file from index without discarding changes in the working directory.

Remote Sync-u <remote> <branch>
git push -u origin feature/auth

Push local branch to remote repository and configure upstream tracking.

Cleanup-fd
git clean -fd

Forcefully remove untracked files and directories from the working directory.

GitHub CLI--title, --body, --web
gh pr create --title "feat: auth" --body "Closes #42" --web

Create a pull request on GitHub directly from the command line and open in browser.

Inspection & History--graph --oneline --all
git log --graph --oneline --decorate --all -n 20

Visualize commit history DAG graph across all local and remote branches in compact single-line format.

Disaster Recovery-n 15
git reflog -n 15

Show the history of HEAD movements to recover deleted branches, dropped stashes, or unlinked commits.

Branching & Worktreesadd <path> <branch>
git worktree add ../hotfix-branch master

Checkout and build a separate branch in an isolated directory simultaneously without stashing or switching directories.

Undoing & Rewriting--amend --no-edit
git commit --amend --no-edit

Add newly staged changes directly into the previous commit without altering the original commit message.

Debugging & Bisectingstart [bad] [good]
git bisect start HEAD v1.0.0 && git bisect run npm test

Binary search through commit history to automatically isolate the exact commit that introduced a regression.

Zero Setup100% In-Browser Execution

Companion Developer Tools & Playgrounds

Accelerate command execution and syntax debugging with HelloAIHub suite of interactive tools.

Explore all developer tools

Git & GitHub CLI: Command Groups & Quick Index

19 indexed entries across 18 sections
Status & Inspection1 items
Branching & Switching1 items
Committing1 items
History & Logs1 items
Interactive Rebasing1 items
Stashing2 items
Undoing & Reset1 items
Cherry-Picking1 items
Diffing1 items
Unstaging1 items
Remote Sync1 items
Cleanup1 items
GitHub CLI1 items
Inspection & History1 items
Disaster Recovery1 items
Branching & Worktrees1 items
Undoing & Rewriting1 items
Debugging & Bisecting1 items

Highlighted Flags & Syntax Examples in Git & GitHub CLI

git status -sb

Show working tree status in short format with branch tracking info.

Flags: -sb
git switch -c feature/auth

Create and immediately switch to a new local feature branch.

Flags: -c <branch>
git commit -m "feat: implement OAuth2 refresh token rotation"

Record staged changes to repository history with a conventional commit message.

Flags: -m <msg>
git log --oneline --graph --decorate --all -n 15

Display visual ASCII branch history with commit hashes, tags, and head pointers.

Flags: --oneline, --graph, --decorate

Frequently Asked Questions

Expert recommendations, common traps, and production best practices for Git & GitHub CLI.

What is the difference between git merge and git rebase?

git merge combines divergent branch histories by creating a dedicated merge commit, preserving exact chronological history. git rebase reapplies commits on top of the target branch tip, producing a clean linear project history without merge bubbles.

How does git reset --soft differ from --hard?

--soft moves HEAD backwards but leaves changes staged in the index. --hard moves HEAD backwards and completely discards all staged and unstaged changes in the working tree, which cannot be easily undone.

How do I fix a detached HEAD state in Git?

A detached HEAD means you checked out a specific commit rather than a branch. Run 'git switch -c new-branch-name' to preserve your current commit pointer into a new branch.

What is git cherry-pick and when should it be used?

cherry-pick copies the diff of a specific commit from one branch and applies it to your current branch. It is ideal for backporting critical bug fixes or security patches to maintenance branches without merging entire feature branches.

What is the difference between git fetch and git pull?

git fetch downloads all remote commit objects, refs, and tags to your local repository without modifying your working branch. git pull is a composite command that executes git fetch followed immediately by git merge (or git rebase if configured), updating your active working files.

How does git stash work internally?

git stash creates two special commit objects: one for modified tracked files in the working directory, and one for changes staged in the index. These commits are linked under refs/stash and can be inspected via git log refs/stash --oneline.

Cross-Hub Skill Acceleration

Combine command lookups with active coding interviews and complete career paths.

Need More Cheat Sheets?

Explore developer cheat sheets and syntax guides on HelloAIHub.

Browse All Cheat Sheets