Distributed, local first
Git Cheat Sheet Reference
The everyday Git commands for staging, committing, branching, and syncing, kept to the ones you actually run in a normal day.
At a glance
Key factsBy Linus Torvalds, 2005
Status, add, commit, push
Cheap, use them freely
Everyday commands
14 rows| Command | What it does |
|---|---|
| git status | Show staged and unstaged changes |
| git add <file> | Stage a file for the next commit |
| git add -A | Stage every change |
| git commit -m "msg" | Record staged changes with a message |
| git log --oneline | Show a compact commit history |
| git diff | Show unstaged line by line changes |
| git branch | List local branches |
| git switch -c <name> | Create and switch to a branch |
| git merge <branch> | Merge a branch into the current one |
| git pull | Fetch and merge from the remote |
| git push | Send local commits to the remote |
| git clone <url> | Copy a remote repository locally |
| git restore <file> | Discard unstaged changes to a file |
| git stash | Shelve changes to reapply later |
Where it comes from
Git is the distributed version control system created by Linus Torvalds in 2005 to manage Linux kernel development. Because every clone holds the full history, most work happens locally and only a push or pull touches the network. The commands below are drawn from the official Git documentation and cover the core loop nearly every project relies on, rather than the full command surface.
How to use it
The daily rhythm is small and repeats. You check status to see what changed, stage the files you mean to keep with add, record them with a commit and a clear message, and push to share. Branching keeps unfinished work off the main line: create a branch, commit on it, then merge it back when it is ready. When you need to line up with others, pull to fetch and merge their commits first. Keep commits focused and messages in the imperative mood, for example add login form rather than added login form, so the log reads like a list of instructions.
This page is a standing reference at a fixed URL, built to be linked and cited. The data here is compiled from the official Git documentation (git-scm.com).