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
.bashrcFile: Ensure that hidden files are visible. If you don't see a.bashrcfile, you'll need to create one. -
Create the
.bashrcFile: Open terminal and run the commandto create and open the file in Notepad. Alternatively, you can create the file using any text editor.C:\Users\UserName> notepad .bashrc
-
Add Your Aliases: In the
.bashrcfile, add your desired aliases using thealiaskeyword. For example:alias ga='git add' alias gaa='git add .' -
Save and Reload: Save the
.bashrcfile 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:
-
gaforgit add -
gaaforgit add . -
gcforgit commit -
gpforgit push