Explore best practices, tutorials, case studies, and insights on leveraging AWS’s vast ecosystem to build, deploy, and manage applications in the cloud
The Design Pattern category explores reusable solutions to common software design challenges, helping developers write efficient, maintainable, and scalable code
The Security category focuses on best practices, tools, and frameworks essential for protecting applications, data, and infrastructure in an increasingly digital world
Comprehensive Guide to Token-Based Authentication & Secure Access Control
Master token-based authentication, OAuth2, API security, and access control strategies like RBAC and ABAC for secure healthcare applications. Learn best practices for token storage, rotation, MFA, and more.
LIKE vs Full-Text Search: SQL Performance and Use Cases
Explore the differences between SQL’s LIKE operator and Full-Text Search. Learn their syntax, performance, use cases, and advanced features for optimizing database queries
10 Advanced JavaScript Tricks Every Developer Should Master
Discover 10 advanced JavaScript techniques, including tail call optimization, currying, proxies, debouncing, throttling, and more. Learn how to write efficient, maintainable, and optimized code for modern web development.
Step-by-Step Guide: Setting Up Git and Shell Aliases on All Operating Systems
Learn how to create Git and shell aliases on Windows, macOS, and Linux. Follow this step-by-step guide to save time, boost productivity, and ensure your shortcuts work perfectly.
2 min read
24 Views
Git and shell aliases are excellent tools to save time and streamline your workflow. This guide walks you through setting up aliases step by step on Windows, macOS, and Linux, ensuring everything works perfectly.
1. What Are Git and Shell Aliases?
• Git Aliases: Shortcuts for common Git commands, defined in your .gitconfig file.
• Shell Aliases: Shortcuts for commands defined in your shell configuration file (e.g., .bashrc, .zshrc, or .powershell_profile).
2. Setting Up Git Aliases
Step 1: Edit Your Git Configuration File
Use the following command to open your Git configuration file:
git config --global -e
Step 2: Add Git Aliases
In the file, add your aliases under the [alias] section. For example:
[alias]
gst = status
gl = pull
gp = push
gco = checkout
gcob = checkout -b
glog = log --oneline --graph
Step 3: Save and Verify
After saving the file, test the aliases:
git gst # Runs 'git status'
git gco main # Checks out the 'main' branch
3. Setting Up Shell Aliases
For Linux and macOS
1. Determine Your Shell
Check which shell you’re using:
echo $SHELL
Common shells include Bash (/bin/bash) and Zsh (/bin/zsh).
2. Edit Your Shell Configuration File
• For Bash:
nano ~/.bashrc
3. Add Aliases
Add your desired aliases at the bottom of the file. For example:
alias gst='git status'
alias gl='git pull'
alias gp='git push'
alias gco='git checkout'
alias gcob='git checkout -b'
4. Save and Reload
• Save the file (Ctrl+O, Enter, Ctrl+X) and reload the configuration:
source ~/.bashrc # For Bash
source ~/.zshrc # For Zsh
5. Test the Aliases
Run:
gco main
For Windows (PowerShell)
1. Open Your PowerShell Profile
Run this command to open your PowerShell profile:
notepad $PROFILE
If the file doesn’t exist, it will be created.
2. Add Aliases
In the file, add your aliases using the following format:
Set-Alias gst git
Set-Alias gl git
Set-Alias gp git
function gco { git checkout $args }
function gcob { git checkout -b $args }
3. Save and Reload
Save the file and reload your PowerShell profile:
. $PROFILE
4. Test the Aliases
Run:
gco main
4. Common Debugging Tips
1. Check Loaded Aliases
• For Linux/macOS:
alias
• For Windows PowerShell:
Get-Alias
2. Reload Configuration
If changes don’t work, reload the shell:
source ~/.zshrc # Or ~/.bashrc
3. Escape Special Characters
If your alias includes special characters (e.g., |, “), escape them properly:
alias gd='git diff | less'
alias glogp='git log --pretty=format:\"%h %s\" --graph'
4. Test Git Aliases
Ensure Git aliases work by running:
git alias
5. Example Use Cases
• Quickly switch branches:
gco feature_branch
• Push changes:
gp
• View a compact Git log:
glog
Conclusion
With these step-by-step instructions, you can set up Git and shell aliases on any operating system, saving you time and reducing repetitive typing. Aliases are simple yet powerful tools that help improve your workflow.
Related Posts
GitHub Actions is a CI/CD tool tightly integrated with GitHub, allowing developers to automate workflows directly within their repositories.
Explore the differences between SQL’s LIKE operator and Full-Text Search. Learn their syntax, performance, use cases, and advanced features for optimizing database queries
Learn how to create stunning gradient text animations with smooth hover effects using simple CSS. Perfect for beginners, this guide provides step-by-step instructions and customization tips to enhance your website design
The FoldedTag component is a versatile UI element designed to add a modern, folded-corner aesthetic to your React applications. By leveraging the power of CSS clip-path, this component creates intricate shapes like folded corners and pentagons, ensuring a unique and eye-catching design.
In this article, we’ll break down a beautifully crafted CSS technique that creates a gradient border effect using a combination of pseudo-elements, gradients, and advanced masking techniques. Let’s dive into the mechanics and understand how this effect works.
Subscribe to our newsletter
Get the latest posts delivered right to your inbox