Git Essentials
Version: 2.xPublished: 2026-01-16git/core
Essential git commands for day-to-day development.
Setup
| Example | Description |
|---|---|
| Set identity Configure your name for commits (also set user.email). |
| Set default branch Use 'main' as the default branch for new repos. |
Inspect
| Example | Description |
|---|---|
| Status Show staged, unstaged, and untracked files. |
| Log View recent commit history in compact format. |
| Diff Show changes staged for the next commit. |
| Blame Show who last modified each line of a file. |
Stage & Commit
| Example | Description |
|---|---|
| Stage all Stage all changes in current directory. |
| Stage interactively Stage changes hunk by hunk. |
| Unstage Remove file from staging area, keep changes. |
| Commit Create a commit with staged changes. |
| Amend Modify the last commit (message or content). |
Branches
| Example | Description |
|---|---|
| Create & switch Create a new branch and switch to it. |
| Switch Switch to an existing branch. |
| List List branches with upstream tracking info. |
| Delete Delete a merged branch (-D to force). |
Remote
| Example | Description |
|---|---|
| Clone Download a repository and its history. |
| Fetch Download refs and clean up deleted remote branches. |
| Pull Fetch and rebase local commits on top. |
| Push Push branch and set upstream tracking. |
Merge & Rebase
| Example | Description |
|---|---|
| Merge Merge another branch into current branch. |
| Rebase Replay commits on top of another base. |
| Continue rebase Continue after resolving conflicts. |
| Cherry-pick Apply a specific commit to current branch. |
Stash
| Example | Description |
|---|---|
| Save Temporarily save uncommitted changes. |
| List Show all stashed changes. |
| Apply Restore and remove most recent stash. |
Undo
| Example | Description |
|---|---|
| Discard changes Discard working tree changes to a file. |
| Revert commit Create a new commit that undoes a previous one. |
| Reset soft Undo last commit, keep changes staged. |
| Reflog Show history of HEAD movements for recovery. |