Git Alias: Create Shortcuts for Git Commands
Git aliases allow you to create shortcuts for frequently used Git commands, making your workflow faster and more efficient.
1. Creating a Git Alias
To create an alias, use:
For example:
Now, you can run git st
instead of git status
.
2. Useful Git Alias Examples
🔹 Shorten Common Commands
📌 These aliases allow you to run commands like:
git co main
→ Instead ofgit checkout main
git br
→ Instead ofgit branch
git cm "Initial commit"
→ Instead ofgit commit -m "Initial commit"
🔹 Create a Better git log
View
📌 Now, running git lg
will display a visual history of commits.
🔹 Undo Last Commit (But Keep Changes)
📌 Running git uncommit
undoes the last commit but keeps your changes.
🔹 Clean Untracked Files
📌 git cleanall
removes untracked files and directories.
3. Listing All Aliases
To see all configured aliases, run:
4. Removing an Alias
If you want to remove an alias:
For example, to remove git co
:
🔹 Conclusion
Git aliases save time and reduce typing. Setting up custom aliases allows you to speed up your workflow and work more efficiently.
Do you want help setting up a specific alias? Let me know! 🚀