api: YAML JSON TOON Database
version: 1.0.0
format: yaml
dataset:
  id: 2798
  slug: git-essential-commands
  title: Git Essential Commands
  description: Common Git commands for everyday version control workflows.
  summary: "Essential git commands with a one-line description: init, clone, add, commit, push, pull, branch, checkout, merge, rebase, stash, log, diff, reset and cherry-pick, extended with status, fetch, restore, switch, tag, blame, bisect, revert, reflog, worktrees and configuration."
  use_when:
    - You need the right git command for a task.
    - You are teaching or learning git from the command line.
  caveats:
    - Some commands rewrite history (rebase, reset --hard, commit --amend); do not use them on commits others have pulled.
    - Newer commands (switch, restore) are clearer than checkout and reset for those tasks.
  related:
    - version-control-workflows
    - cicd-pipeline-stages
    - file-operations
    - shell-scripting-guide
    - git-recovery-workflows
    - shell-safe-file-patterns
  sources:
    - title: Git restore and recovery documentation
      url: "https://git-scm.com/docs/git-restore"
  reading:
    - recover-git-work-without-losing-local-changes
  reviewed_at: "2026-10-12"
  provenance: Original editorial reference notes by YJTOON, informed by the linked primary documentation. External specifications retain their own licenses.
  entry_count: 36
  fields:
    - section: data
      field: command
      type: string
      example: git init
    - section: data
      field: description
      type: string
      example: Initialize a new Git repository in the current …
  category: Unix Commands
  category_slug: unix-commands
  tags: unix,git,version-control,vcs
  view_count: 38
  created_at: 1793403093
  updated_at: 1791799373
data:
  - command: git init
    description: Initialize a new Git repository in the current directory.
  - command: git clone <url>
    description: Clone a remote repository to your local machine.
  - command: git add <file>
    description: Stage changes for the next commit. Use git add . for all.
  - command: "git commit -m \"msg\""
    description: Commit staged changes with a descriptive message.
  - command: git push
    description: Upload local commits to the remote repository.
  - command: git pull
    description: Fetch and merge changes from the remote branch.
  - command: git branch -a
    description: List all local and remote branches.
  - command: git checkout <branch>
    description: Switch to the specified branch. Use -b to create and switch.
  - command: git merge <branch>
    description: Merge the specified branch into the current branch.
  - command: git rebase <branch>
    description: Reapply commits on top of another branch. Use with caution on public branches.
  - command: git stash
    description: Temporarily store uncommitted changes. Use git stash pop to restore.
  - command: git log --oneline -10
    description: Show the last 10 commits in compact format.
  - command: git diff
    description: Show unstaged changes. Use git diff --staged for staged changes.
  - command: git reset --soft HEAD~1
    description: Undo the last commit, keeping changes staged.
  - command: git cherry-pick <hash>
    description: Apply a specific commit by hash onto the current branch.
  - command: git status
    description: Show changed, staged and untracked files.
  - command: git fetch
    description: Download remote changes without merging them.
  - command: git restore <file>
    description: Discard working-tree changes to a file; use --staged to unstage.
  - command: git switch -c <branch>
    description: Create a new branch and switch to it.
  - command: git diff --staged
    description: Show changes that are staged for the next commit.
  - command: git commit --amend
    description: Modify the most recent commit; avoid after pushing.
  - command: git stash pop
    description: Reapply the most recent stash and remove it from the stash list.
  - command: git revert <hash>
    description: Create a new commit that undoes an earlier one without rewriting history.
  - command: git log --graph --oneline --all
    description: Show a compact graph of all branches.
  - command: git blame <file>
    description: Show who last changed each line of a file.
  - command: git bisect start
    description: Begin a binary search through history to find the commit that introduced a bug.
  - command: "git tag -a v1.0 -m \"msg\""
    description: Create an annotated tag for a release.
  - command: git reflog
    description: List where HEAD has been, useful for recovering lost commits.
  - command: git branch -d <branch>
    description: Delete a branch that has been merged.
  - command: git remote -v
    description: List remotes and their URLs.
  - command: git worktree add <path> <branch>
    description: Check out another branch in a separate directory.
  - command: "git config --global user.name \"Name\""
    description: Set the author name used for commits.
  - command: git restore --staged -- path
    description: Unstage a path while retaining its working-tree contents. Add -- before a path that could be read as an option.
  - command: git diff --check
    description: Find conflict markers and whitespace errors in the current diff before committing.
  - command: git log --all -- path
    description: Inspect commits touching a path across all refs, without changing files.
  - command: git stash show -p stash@{0}
    description: Inspect the latest stash patch before deciding whether to apply it.
