Hoai-Nho-Logo

/

Blog

AboutProjectsBlogContact

All topics

Architecture & Design

Architecture & Design
Discover cutting-edge architecture and design ideas. Explore innovative projects, modern interior design trends, sustainable architecture, and creative design solutions to inspire your next project.aws saa-c03
AWS

Explore best practices, tutorials, case studies, and insights on leveraging AWS’s vast ecosystem to build, deploy, and manage applications in the cloud

Design patterns

The Design Pattern category explores reusable solutions to common software design challenges, helping developers write efficient, maintainable, and scalable code

Docker
Explore essential Docker tutorials and resources. Find helpful tips, best practices, and tools to master containerization and improve your deployment workflow.
Security

The Security category focuses on best practices, tools, and frameworks essential for protecting applications, data, and infrastructure in an increasingly digital world

SSL license expired?

Ultimate Guide to Renewing SSL Certificates: Secure Your Website in 2024

Ensure your website stays secure! 🔒 Learn how to check, renew, and manage your SSL certificate to prevent security risks and downtime. Follow our step-by-step guide with best practices to keep your HTTPS protection active in 2024!

CSS

Database

Database
Find easy-to-follow guides on database SQL, NoSQL, PostgreSQL, and MySQL. Learn how to make databases that are fast and work well. Get tips to improve your skills. database
MySQL
Discover essential database guides covering SQL, NoSQL, and best practices. Get tips and performance benchmarks to improve your data management skills.
NoSQL
Discover essential database guides covering SQL, NoSQL, and best practices. Get tips and performance benchmarks to improve your data management skills.
PostgreSQL
Explore comprehensive PostgreSQL tutorials and resources. Find helpful tips, best practices, and performance benchmarks to enhance your database skills.
Search topic

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

Generation

Interview Question

NodeJS

NodeJS
Explore beginner to advanced tutorials on JavaScript and TypeScript. Find helpful tips, best practices, and tools to create powerful web applications. typescript_vs_javascript
Javascript/Typescript
Learn JavaScript and TypeScript with easy guides. Discover tips, best practices, and tools to build efficient web applications quickly.
tripple-cache

🚀 Triple-Layered Web Caching Strategy: How Memory, IndexedDB and HTTP Cache Improved Speed by 96%

Discover how to accelerate your website through our powerful triple-layered caching strategy combining Memory Cache, IndexedDB, and HTTP Cache. Detailed guidance from theory to practice helps reduce page load time by up to 96%, improve user experience, and optimize performance across all devices.


© 2025 Hoai Nho. All rights reserved.

ContactGitHubLinkedIn
  1. Home
  2. /Blog
  3. /Step-by-Step Guide: Setting Up Git and Shell Aliases on All Operating Systems

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.

Git alias
Hoài Nhớ@hoainho
December 13, 2024
|

2 min read

|

308 Views

Share:

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.


Tags:
Git AliasTipsTools
Written by

author
Hoài Nhớ

Hoài Nhớ

@Hoài Nhớ
Git AliasTipsTools

Table of Contents

    References posts

    Github Action Interview: CICD Pipeline

    GitHub Actions is a CI/CD tool tightly integrated with GitHub, allowing developers to automate workflows directly within their repositories.

    Hoài Nhớ
    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

    Hoài Nhớ
    🚀 Triple-Layered Web Caching Strategy: How Memory, IndexedDB and HTTP Cache Improved Speed by 96%

    Discover how to accelerate your website through our powerful triple-layered caching strategy combining Memory Cache, IndexedDB, and HTTP Cache. Detailed guidance from theory to practice helps reduce page load time by up to 96%, improve user experience, and optimize performance across all devices.

    Hoài Nhớ
    Related Posts

    Github Action
    CI/CDGithub Action
    Github Action Interview: CICD Pipeline

    GitHub Actions is a CI/CD tool tightly integrated with GitHub, allowing developers to automate workflows directly within their repositories.

    Hoài Nhớ
    Search topic
    ElasticSearchFull-Text Search
    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

    Hoài Nhớ
    tripple-cache
    FrontendOptimizationIndexedDB
    🚀 Triple-Layered Web Caching Strategy: How Memory, IndexedDB and HTTP Cache Improved Speed by 96%

    Discover how to accelerate your website through our powerful triple-layered caching strategy combining Memory Cache, IndexedDB, and HTTP Cache. Detailed guidance from theory to practice helps reduce page load time by up to 96%, improve user experience, and optimize performance across all devices.

    Hoài Nhớ
    Redux Thunk and Saga
    Redux SagaRedux Thunk
    Redux Thunk vs Redux Saga: A Deep Dive into Strengths, Weaknesses, and Hidden Pitfalls

    This article explores the core differences between Redux Thunk and Redux Saga, highlighting their strengths, weaknesses, and best use cases. Whether you’re building a small application or managing complex asynchronous workflows, understanding these middleware options will help you make the right choice for your Redux architecture.

    Hoài Nhớ
    Breakings NewsReact19
    🚀 React 19 Deep Dive: A Senior Engineer’s Practical Guide to New Hooks

    An in-depth analysis of React 19’s new hooks from a 20-year veteran engineer’s perspective. Learn practical implementation strategies, best practices, and real-world use cases for use(), useFormState(), useFormStatus(), and useOptimistic() hooks.

    Hoài Nhớ

    Subscribe to our newsletter

    Get the latest posts delivered right to your inbox