Why Use Aliases?
Typing out full Git commands repeatedly can be tedious, especially when you're under pressure to complete urgent tasks. Fortunately, you can save time by creating shortcuts, or aliases, for your most-used Git commands. Here's a straightforward guide to setting up these aliases in Git Bash on Windows.
Steps to Create Git Aliases
-
Navigate to Your User Directory: Open File Explorer and go to
C:\Users\{username}
. -
Check for the
.bashrc
File: Ensure that hidden files are visible. If you don't see a.bashrc
file, you'll need to create one. -
Create the
.bashrc
File: Open terminal and run the commandC:\Users\UserName> notepad .bashrc
-
Add Your Aliases: In the
.bashrc
file, add your desired aliases using thealias
keyword. For example:alias ga='git add' alias gaa='git add .' -
Save and Reload: Save the
.bashrc
file and close Notepad. To apply the changes, reopen Git Bash from your project folder.
Example Aliases
Here are a few example aliases to get you started:
-
ga
forgit add
-
gaa
forgit add .
-
gc
forgit commit
-
gp
forgit push