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