This page lists 83 keyboard shortcuts for Git on macOS. All shortcuts fall under the General category, so the page covers core command-line interactions rather than a specific workflow area.
App Cheat Sheet
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Git keyboard shortcuts are organized by category and available for Windows, macOS, and Linux. Search by keyword or browse by section.
| Action | Hotkey |
|---|---|
| Compare remote branch master with local branch master | Git diff origin/master..master |
| Show 1 line of log -n for n lines | Git log -1 |
| Show changes added to index but not yet committed | Git diff --cached |
| Show 5 lines of log | Git log -5 |
| Configure email | Git config --global user.email 'xxx@xxx.com' |
| Show all commits, including isolated nodes | Git reflog |
| Show detailed content of a commit | Git log -p -m |
| View all stashes | Git stash list |
| Show the state of the master branch yesterday | Git show master@{yesterday} |
| Apply the first stash | Git stash apply stash@{0} |
| Rename file README to README2 | Git mv README README2 |
| Show commit logs | Git log |
| Show logs of v2.0 | Git log v2.0 |
| Get all remote branches (without updating local branches, need merge separately) | Git fetch |
| Configure username | Git config --global user.name 'xxx' |
| Commit | Git commit -m 'xxx' |
| Compare with the HEAD version of the lib directory | Git diff HEAD -- ./lib |
| Get remote branch master and merge into current branch | Git pull origin master |
| Compare with the previous version | Git diff HEAD^ |
| Rename local branch | Git branch -m master master_copy |
| Show local branches | Git branch |
| Show detailed content of a commit | Git show dfb02e6e4f2f7b573337763e5c0013802e392818 |
| Recursively delete | Git rm -r * |
| Show detailed content of a commit | Git show dfb02 |
| Show logs and detailed content of v2.0 | Git show v2.0 |
| Show commit log | Git show HEAD~3 |
| Check out remote branch hotfixes/BJVEP933 and create local tracking branch | Git checkout --track hotfixes/BJVEP933 |
| Revert commit dfb02e6e4f2f7b573337763e5c0013802e392818 | Git revert dfb02e6e4f2f7b573337763e5c0013802e392818 |
| Reset current version to HEAD (usually used for failed merge rollback) | Git reset --hard HEAD |
| Check current version status (whether modified) | Git status |
| List files contained in git index | Git ls-files |
| Check out README file of head version (for error rollback) | Git checkout -- README |
| Create new local branch devel from remote branch develop and check out | Git checkout -b devel origin/develop |
| Force delete branch hotfixes/BJVEP933 | Git branch -D hotfixes/BJVEP933 |
| Add all modified files in the current subdirectory to index | Git add . |
| Automatically colorize git status | Git config --global color.status auto |
| Show all original branches | Git branch -r |
| Show branches containing commit 50089 | Git branch --contains 50089 |
| Internal command: Show the SHA1 HASH of a ref | Git rev-parse v2.0 |
| Push all tags to remote repository | Git push --tags |
| Automatically colorize git status and other commands | Git config --global color.ui true |
| Automatically colorize git diff | Git config --global color.diff auto |
| Automatically colorize git branch | Git config --global color.branch auto |
| Show branches not merged into the current branch | Git branch --no-merged |
| Show all branch history | Git show-branch --all |
| Delete branch hotfixes/BJVEP933 (branch modifications have been merged into other branches) | Git branch -d hotfixes/BJVEP933 |
| Combine add and commit into one step | Git commit -am 'xxx' |
| Remove proxy configuration on git | Git config --global --unset http.proxy |
| Complete version of the above | Git checkout -b master master_copy |
| Show current branch history | Git show-branch |
| Remove file from index | Git rm 'xxx' |
| Add remote definition (for push/pull/fetch) | Git remote add origin git+ssh://git@192.168.53.168/VT.git |
| Show commit log | Git log --pretty=format:'%h %s' --graph |
| Check out version v2.0 | Git checkout v2.0 |
| Show existing tags | Git tag |
| Merge changes of commit ff44785404a8e | Git cherry-pick ff44785404a8e |
| Only show different files, do not show specific content | Git diff origin/master..master --stat |
| Show branches merged into the current branch | Git branch --merged |
| Show all changes not added to index | Git diff |
| Merge remote master branch into current branch | Git merge origin/master |
| Show all branches | Git branch -a |
| Clone remote repository | Git clone git+ssh://git@192.168.53.168/VT.git |
| Add tag v2.0 | Git tag -a v2.0 -m 'xxx' |
| Initialize local git repository (create new repository) | Git init |
| Add xyz file to index | Git add xyz |
| Show commit logs and related changed files | Git log --stat |
| Internal command: Show a git object | Git ls-tree HEAD |
| Show the state of HEAD 5 commits ago | Git show HEAD@{5} |
| Rebase | Git rebase |
| Show HEAD commit logs | Git show HEAD |
| Create new branch master_copy from current branch and check out | Git checkout -b master_copy |
| Get all original branches and clear branches deleted on the server | Git fetch --prune |
| Show commit log | Git show -s --pretty=raw 2be7fcb476 |
| Merge the last commit (for repeated modifications) | Git commit --amend -m 'xxx' |
| Stash current changes and set all to HEAD state | Git stash |
| Check out existing features/performance branch | Git checkout features/performance |
| Show file modifications corresponding to commit history | Git whatchanged |
| Automatically colorize git interactive | Git config --global color.interactive auto |
| Reference the first stash | Git stash show -p stash@{0} |
| Show parent commit logs of HEAD (previous version) | Git show HEAD^ |
| Search for text "delete from" in files | Git grep 'delete from' |
| Push current branch to remote master branch | Git push origin master |
| Delete remote branch hotfixes/BJVEP933 | Git push origin :hotfixes/BJVEP933 |
228 hotkeys
208 hotkeys