The Ultimate Git Cheatsheet – Every Command You’ll Ever Need
Whether you're just getting started with version control or you’re a seasoned contributor working on large-scale collaborative projects, Git remains an essential part of every developer’s toolkit. But with dozens of commands and flags, it’s easy to forget the syntax or the best option to use in a given scenario.
This cheatsheet provides a categorized, ready-to-use reference of all the most useful Git commands. From setting up a repository to resolving complex merge conflicts — this is your go-to guide.
| # | Category | Command | Purpose |
|---|---|---|---|
| 1 | Config | | Set global Git username |
| 2 | | Set global Git email | |
| 3 | | Enable colorized Git output | |
| 4 | Init | | Initialize a new Git repository |
| 5 | Clone | | Clone a remote repository |
| 6 | Status | | Display the state of the working directory and staging area |
| 7 | Add | | Add a file to the staging area |
| 8 | | Add all changes in the current directory to the staging area | |
| 9 | Commit | | Commit staged changes with a message |
| 10 | | Amend the previous commit | |
| 11 | Branch | | List all local branches |
| 12 | | List all branches, including remote | |
| 13 | | Create a new branch | |
| 14 | | Delete a local branch | |
| 15 | Checkout | | Switch to an existing branch |
| 16 | | Create and switch to a new branch | |
| 17 | Merge | | Merge a branch into the current branch |
| 18 | Rebase | | Reapply commits on top of another base tip |
| 19 | Reset | | Reset current HEAD to the specified state |
| 20 | | Roll back the current branch by two commits | |
| 21 | | Reset HEAD to the specified commit, keeping changes staged | |
| 22 | Revert | | Revert a commit by creating a new commit |
| 23 | Log | | Show commit logs |
| 24 | | Show condensed commit logs | |
| 25 | Diff | | Show changes between commits, commit and working tree, etc |
| 26 | | Show changes between staged changes and last commit | |
| 27 | Stash | | Stash the changes in a dirty working directory |
| 28 | | List all stashed changes | |
| 29 | | Apply stashed changes | |
| 30 | | Apply and remove the latest stash | |
| 31 | Remote | | Show remote connections |
| 32 | | Add a new remote repository | |
| 33 | Fetch | | Download objects and refs from another repository |
| 34 | Pull | | Fetch from and integrate with another repository or a local branch |
| 35 | Push | | Update remote refs along with associated objects |
| 36 | Tag | | List tags |
| 37 | | Create a new tag | |
| 38 | | Delete a tag | |
| 39 | | Push a tag to remote | |
| 40 | | Delete a remote tag | |
| 41 | Reflog | | Show history of HEAD |
| 42 | Cherry-pick | | Apply the changes introduced by some existing commits |
| 43 | Bisect | | Use binary search to find the commit that introduced a bug |
| 44 | Blame | | Show what revision and author last modified each line of a file |
| 45 | Clean | | Remove untracked files from the working directory |
| 46 | Show | | Show various types of objects |
| 47 | Submodule | | Add a new submodule |
| 48 | | Initialize and update submodules | |
| 49 | | Synchronize submodule URLs | |
| 50 | Help | | Get help for a specific Git command |