Git and GitHub Desktop Shortcut Keys: Complete List (With Functions Explained)

Git itself runs on commands, but the pros turn the long ones into short "shortcut" commands called aliases — and the GitHub Desktop app has true keyboard shortcuts on top. This complete guide covers the essential Git commands every developer types daily, how to create your own Git shortcut keys (aliases), and the GitHub Desktop keyboard shortcuts (Windows; use Cmd instead of Ctrl on macOS).

Essential Git Commands (the daily set)

CommandFunction
git initCreate a new Git repository in the current folder
git clone <url>Download a copy of a remote repository
git statusShow changed, staged and untracked files
git add <file>Stage one file for the next commit
git add .Stage all changes in the current folder
git commit -m "message"Commit the staged changes with a message
git commit -am "message"Stage tracked files and commit in one step
git logShow the commit history
git log --oneline --graphCompact history drawn as a branch graph
git diffShow unstaged changes
git diff --stagedShow staged changes (what will be committed)
git branchList branches
git checkout -b <name>Create a branch and switch to it
git switch <name>Switch branches (modern command)
git merge <name>Merge a branch into the current one
git fetchDownload remote changes without merging
git pullFetch and merge the remote changes
git pushUpload your commits to the remote
git push -u origin <branch>Push a new branch and remember its upstream
git stashShelve uncommitted changes temporarily
git stash popRestore the most recently stashed changes
git restore <file>Discard changes in a file
git reset --soft HEAD~1Undo the last commit but keep the changes staged
git reset --hard HEAD~1Undo the last commit and DELETE its changes (careful)
git revert <commit>Undo a commit safely with a new inverse commit
git cherry-pick <commit>Copy one commit onto the current branch
git rebase -i HEAD~3Interactively edit/reorder/squash the last 3 commits
git remote -vShow the connected remote repositories
git config --global user.name "Your Name"Set your commit identity (one-time setup, with user.email likewise)

Create Your Own Git Shortcut Keys (Aliases)

Setup Command (run once)Shortcut It Creates
git config --global alias.st statusgit st — the status shortcut
git config --global alias.co checkoutgit co — switch branches fast
git config --global alias.br branchgit br — list branches
git config --global alias.cm "commit -m"git cm "message" — commit with a message
git config --global alias.last "log -1 HEAD"git last — show only the latest commit
git config --global alias.lg "log --oneline --graph --all"git lg — the pretty branch graph history
git config --global alias.unstage "reset HEAD --"git unstage file — unstage a file
git config --global alias.amend "commit --amend --no-edit"git amend — fold staged changes into the last commit

GitHub Desktop App Shortcuts

Shortcut KeyFunction
Ctrl + NCreate a new repository
Ctrl + Shift + OClone a repository
Ctrl + OAdd an existing local repository
Ctrl + 1Show the Changes tab
Ctrl + 2Show the History tab
Ctrl + EnterCommit to the current branch (from the commit form)
Ctrl + PPush the repository
Ctrl + Shift + PPull the repository
Ctrl + Shift + FFetch the repository
Ctrl + , (comma)Open Preferences/Options
Ctrl + Shift + IOpen the developer tools (app debugging)

Tips for Git Users

Muscle memory order: status → add → commit → push is the loop; learn those four first and alias them (st, cm). git log --oneline --graph --all (alias lg) answers "what does my history look like" in one glance. And prefer git revert over reset --hard on anything already pushed — revert creates a new commit, so teammates' clones stay valid.

Frequently Asked Questions

How do I create a shortcut for a Git command?

Run git config --global alias.<short> "<full command>" once — for example alias.st for status. From then on, git st runs git status.

What is the difference between git fetch and git pull?

Fetch only downloads the new commits so you can inspect them; pull downloads AND merges them into your current branch immediately.

How do I undo the last commit in Git?

git reset --soft HEAD~1 undoes the commit and keeps your changes staged. Use git revert for commits that were already pushed.

How do I see a compact history in Git?

git log --oneline --graph --all shows each commit on one line with branch lines drawn in — most users alias it to git lg.

By Umar Farooq, Tech Know.

Post a Comment

0 Comments