Command Shortcuts (Aliases)
You’ve been typing git status dozens of times today, haven’t you? Your fingers
are probably getting tired. Good news: Git lets you create shortcuts (called
“aliases”) for commands you use frequently.
Think of aliases as speed dial for your Git commands. Instead of typing
git status every time, you could just type git st. Two characters instead of
six. Over a day of development, that adds up.
But here’s the important part: don’t create aliases for commands you’re still
learning. Muscle memory for the actual commands is important first. Once
you’ve internalized what git status does, then you can shortcut it to
git st.
Your First Aliases
Start with the commands you’ve just learned in Getting Started. These are the ones you’ll type most often.
Status - Your Most-Used Command
git config --global alias.st statusNow you can type:
git stInstead of git status. It does exactly the same thing, just faster.
Commit - Save Those Snapshots Quickly
git config --global alias.ci commitUsage:
git ci -m "Add user login feature"Why “ci”? It’s a convention from older version control systems (CVS) where “check in” meant saving changes. Many developers still use it.
Branch - See and Manage Branches
git config --global alias.br branchUsage:
git br # List branches
git br feature-new-ui # Create branchSwitch - Jump Between Branches
git config --global alias.sw switchUsage:
git sw main
git sw -c feature-paymentSetting Up Your First Aliases
You have two ways to create aliases:
Option 1: Command Line (Recommended for Beginners)
Just type each command once:
git config --global alias.st status
git config --global alias.ci commit
git config --global alias.br branch
git config --global alias.sw switchThe --global flag means these aliases work in all your Git repositories, not
just the current one.
Option 2: Edit Config File Directly
Open ~/.gitconfig in your text editor and add:
[alias]
st = status
ci = commit
br = branch
sw = switchThis does the same thing as the command-line approach, just faster if you’re setting up multiple aliases at once.
Try Them Out
After setting up these aliases, test them:
# Check your status
git st
# Create a new branch
git br test-aliases
# Switch to it
git sw test-aliases
# Make a change and commit
echo "Testing aliases" > test.txt
git add test.txt
git ci -m "Test commit using alias"
# Success! Your aliases are workingA Word of Caution
It’s tempting to create aliases for everything right away. Resist that urge.
Why? Because you’re still building intuition for what these commands do. If you immediately shortcut everything to cryptic abbreviations, you lose the connection between the command name and its purpose.
git status tells you it’s checking status. git st is just two letters.
The rule: Only create aliases for commands you use so frequently that typing the full name feels genuinely tedious. If you have to think “what did I alias this to?”, you aliased it too early.
What’s Next?
These four aliases (st, ci, br, sw) will handle 80% of your basic Git
workflow. They’re the foundation.
As you progress through the Everyday Git section, you’ll learn more commands worth aliasing:
- Log visualization shortcuts
- Diff shortcuts
- Stashing shortcuts
And in the Advanced section, you’ll discover power-user aliases for complex operations.
But for now, stick with these four. Master the basic workflow. Let your fingers learn the rhythm of Git. The shortcuts will be there when you’re ready for them.
Viewing Your Aliases
Forgot what aliases you’ve set up?
git config --get-regexp aliasThis shows all your configured aliases.
Or open ~/.gitconfig and look at the [alias] section.
The Philosophy of Aliases
Aliases should make you faster, not confuse you. The best aliases are:
- Memorable - Easy to remember what they do
- Consistent - Follow common conventions (
stfor status,cifor commit) - Earned - You’ve used the full command enough to appreciate the shortcut
- Yours - Customize them as your workflow evolves
Don’t copy someone else’s massive alias collection from the internet (yet). Build your own collection gradually as you discover your personal workflow patterns.
Start with these four. Learn the tools. Speed comes with practice, not just shortcuts.
Ready to learn more Git commands? Head to the Everyday Git section, which explores the workflows you’ll use daily. Check out Everyday Git Aliases for more aliases once you’re comfortable with the basics.