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)
| Command | Function |
|---|---|
| git init | Create a new Git repository in the current folder |
| git clone <url> | Download a copy of a remote repository |
| git status | Show 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 log | Show the commit history |
| git log --oneline --graph | Compact history drawn as a branch graph |
| git diff | Show unstaged changes |
| git diff --staged | Show staged changes (what will be committed) |
| git branch | List 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 fetch | Download remote changes without merging |
| git pull | Fetch and merge the remote changes |
| git push | Upload your commits to the remote |
| git push -u origin <branch> | Push a new branch and remember its upstream |
| git stash | Shelve uncommitted changes temporarily |
| git stash pop | Restore the most recently stashed changes |
| git restore <file> | Discard changes in a file |
| git reset --soft HEAD~1 | Undo the last commit but keep the changes staged |
| git reset --hard HEAD~1 | Undo 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~3 | Interactively edit/reorder/squash the last 3 commits |
| git remote -v | Show 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 status | git st — the status shortcut |
| git config --global alias.co checkout | git co — switch branches fast |
| git config --global alias.br branch | git 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 Key | Function |
|---|---|
| Ctrl + N | Create a new repository |
| Ctrl + Shift + O | Clone a repository |
| Ctrl + O | Add an existing local repository |
| Ctrl + 1 | Show the Changes tab |
| Ctrl + 2 | Show the History tab |
| Ctrl + Enter | Commit to the current branch (from the commit form) |
| Ctrl + P | Push the repository |
| Ctrl + Shift + P | Pull the repository |
| Ctrl + Shift + F | Fetch the repository |
| Ctrl + , (comma) | Open Preferences/Options |
| Ctrl + Shift + I | Open 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.
0 Comments