MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

Bash Git Aliases: A Practical Command Set for Faster Daily Git Work

Originally published on 2012-04-11; fully revised and updated.

If you run Git commands all day, short Bash aliases can remove repetitive typing and speed up routine actions like status checks, staging, commits, and pushes. This guide gives you a corrected alias set for ~/.bashrc, explains how it differs from Git-native aliases, and shows a safe workflow for adding and validating aliases.

Bash aliases for Git

What these aliases are (and are not)

The original post lists Bash aliases, not Git configuration aliases. That means they are interpreted by your shell and typically stored in ~/.bashrc (or another shell startup file).

Important correction: in Bash, alias syntax should not include spaces around =. For example, use alias g='git status', not alias g = "git status".

Bash aliases vs Git aliases

OptionDefined inHow you run itBest for
Bash aliasShell config (for example ~/.bashrc)g, ga, gpsVery short commands in interactive shell sessions
Git aliasGit config (for example ~/.gitconfig)git st, git coGit-specific shortcuts that travel with Git config

Drop-in Bash alias set for common Git commands

This is a corrected version of the original alias collection, ready to paste into ~/.bashrc.

alias g='git status'
alias ga='git add'
alias gaa='git add .'
alias gc='git commit -m'
alias gca='git commit -am'
alias gb='git branch'
alias gbd='git branch -d'
alias gco='git checkout'
alias gcob='git checkout -b'
alias gm='git merge'
alias gr='git rebase'
alias gl='git log'
alias gs='git show'
alias gd='git diff'
alias gbl='git blame'
alias gps='git push'
alias gpl='git pull'Code language: JavaScript (javascript)

Install and reload safely

  • Back up your current Bash config before editing.
  • Add the aliases to ~/.bashrc.
  • Reload your shell configuration.
  • Run a quick smoke test.
cp ~/.bashrc ~/.bashrc.bak.$(date +%Y%m%d)

# Edit ~/.bashrc in your preferred editor, then reload:
source ~/.bashrc

# Quick checks:
type g
type ga
gCode language: PHP (php)

Daily Git workflow with aliases

flowchart TD
    A[Edit files] --> B[Run g for status]
    B --> C[Stage with ga or gaa]
    C --> D[Commit with gc message]
    D --> E[Push with gps]
    E --> F[Sync with team]

Alias reference

AliasExpands toTypical use
ggit statusCheck current repo state
gagit addStage specific files
gaagit add .Stage all changes in current directory tree
gcgit commit -mCreate commit with inline message
gcagit commit -amCommit tracked-file changes quickly
gbgit branchList/manage branches
gbdgit branch -dDelete merged branch
gcogit checkoutSwitch branch or restore path behavior via checkout
gcobgit checkout -bCreate and switch to new branch
gmgit mergeMerge branch history
grgit rebaseRebase local work
glgit logInspect commit history
gsgit showShow commit details
gdgit diffInspect unstaged or staged changes (with options)
gblgit blameTrace line-level authorship
gpsgit pushPush branch to remote
gplgit pullFetch and integrate remote changes

If you prefer Git-native aliases

Git-native aliases are configured in Git instead of Bash. They are invoked as git <alias>.

git config --global alias.st status
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commitCode language: CSS (css)

Common pitfalls and best practices

  • Do not use spaces around = in Bash alias definitions.
  • Remember that gca (git commit -am) does not include new untracked files.
  • Quote commit messages when using gc, for example: gc "fix login timeout".
  • Keep a backup of ~/.bashrc before bulk edits.
  • For teams, document your alias set so onboarding is consistent.

Note: the original page also contained a YouTube gallery embed that currently reports an API key restriction error. Direct link preserved from the source: https://www.youtube.com/watch?v=ZCfrNvu6nMc.

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

Shell script to add and commit in 10 files at a time and push

Rajesh Kumar I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have…

Read More

Shell script to git add and commit and push each directory at a time

This script will loop through each directory in the repository, checking if it is a Git repository. If it is, it will add all changes in the…

Read More

AWS Tutorials: Working with Code Commit

AWS CodeCommit is a managed, private Git hosting service. You create a repository in a Region, sign in with IAM-based credentials, and then use normal Git commands…

Read More

Shell Bash Scripting: Assignment & Excercise – 7

This exercise uses Bash, rsync and SSH to copy a local file to a remote backup server, then sends an email when the copy finishes. Below the…

Read More

Git Lab Exercise & Assignment: Git cherry-pick: Part – 12

git cherry-pick copies one or more existing commits from another branch and applies them as new commits on your current branch. This lab corrects and completes the…

Read More

Git Lab Exercise & Assignment: Changing History with Amend: Part – 5

This lab covers three ways to rewrite local Git history: fixing the last commit with git commit –amend, reordering commits with git rebase -i, and undoing it…

Read More
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Puja kushwaha
Puja kushwaha
30 days ago

Bash aliases can make frequent Git tasks faster, especially when switching branches or checking recent changes. The most useful aliases are short but still easy to understand, so they do not hide what a command will do. It is wise to keep destructive actions like reset or force push out of shortcuts unless safeguards are clear. Sharing a small, documented alias file can also help teams use consistent workflows. Testing aliases in a sample repository first can prevent mistakes in active projects.

1
0
Would love your thoughts, please comment.x
()
x