DEV Community

Kaushik Thirthappa for Spike.sh

Posted on • Edited on

Simple git aliases for daily purpose

On average, every developer commits their code atleast once a day.

Having some git aliases help you quickly make changes and push your code.

No more typos

One of my daily frustrations in the past 🀬 -

Alt Text

Avoid common pitfalls are super important, it helps increase productivity in the long term.

Table of contents

ps: These are aliases I have been using personally, feel free to create and share your own ☺️

1. git status πŸ‘‰ gs

Before -

git status
Enter fullscreen mode Exit fullscreen mode

After -

gs
Enter fullscreen mode Exit fullscreen mode

Setup code -

alias gs='git status'
Enter fullscreen mode Exit fullscreen mode

2. git commit πŸ‘‰ gc

Before -

git commit -m 'Adding integration test cases'
Enter fullscreen mode Exit fullscreen mode

After -

gc 'Adding integration test cases'
Enter fullscreen mode Exit fullscreen mode

Setup code -

alias gc='git commit -m $2'
Enter fullscreen mode Exit fullscreen mode

3. git push πŸ‘‰ gp

Before -

git push
Enter fullscreen mode Exit fullscreen mode

After -

gp
Enter fullscreen mode Exit fullscreen mode

Setup code -

alias gp='git push'
Enter fullscreen mode Exit fullscreen mode

4. git add . && git commit -m πŸ‘‰ gac

Before -

git add .
git commit -m 'Adding integration test cases'
Enter fullscreen mode Exit fullscreen mode

After -

gac 'Adding integration test cases'
Enter fullscreen mode Exit fullscreen mode

Setup code -

alias gac='git add . && git commit -m $2'
Enter fullscreen mode Exit fullscreen mode

5. git add . && git commit -m && git push πŸ‘‰ gacp

Before -

git add .
git commit -m 'Adding integration test cases'
git push
Enter fullscreen mode Exit fullscreen mode

After -

gacp 'Adding integration test cases'
Enter fullscreen mode Exit fullscreen mode

Setup code -

alias gacp='git add . && git commit -m $2 && git push'
Enter fullscreen mode Exit fullscreen mode

6. git stash πŸ‘‰ gst

Before -

git stash
Enter fullscreen mode Exit fullscreen mode

After -

gst
Enter fullscreen mode Exit fullscreen mode

Setup code -

alias gst='git stash'
Enter fullscreen mode Exit fullscreen mode

6. git stash apply πŸ‘‰ gsta

Before -

git stash apply
Enter fullscreen mode Exit fullscreen mode

After -

gsta
Enter fullscreen mode Exit fullscreen mode

Setup code -

alias gsta='git stash apply'
Enter fullscreen mode Exit fullscreen mode

6. git push --set-upstream origin πŸ‘‰ gpst

This syntax is the one I forget the most πŸ€·β€β™€οΈ

Before -

git push --set-upstream origin integration-tests
Enter fullscreen mode Exit fullscreen mode

After -

gpst integration-tests
Enter fullscreen mode Exit fullscreen mode

Setup code -

alias gpst='git push --set-upstream origin $1'
Enter fullscreen mode Exit fullscreen mode

6. git checkout πŸ‘‰ gco

Before -

git checkout staging
Enter fullscreen mode Exit fullscreen mode

After -

gco staging
Enter fullscreen mode Exit fullscreen mode

Setup code -

alias gco='git checkout $1'
Enter fullscreen mode Exit fullscreen mode

These are the aliases that I use everyday for the past few years. No typos, no errors and super handy.

Top comments (1)

Collapse
 
dmahely profile image
Doaa Mahely

I’ve been wanting to setup aliases for my git workflow forever. The alias I want the most is for fetching a remote branch and checking out to it.