DEV Community

Cover image for GitHub Alias FTW!
Neto Hog
Neto Hog

Posted on

GitHub Alias FTW!

You know that command that you have to Google every time you need it, or those sequential commands that repeat themselves several times during your day?

You can create an alias to make your life easier and use those extra seconds you will save to share this tip with your colleagues! Win-win situation! ๐Ÿ™ƒ

git config --global alias.<alias> '<command>'
Enter fullscreen mode Exit fullscreen mode

For instance, by setting up this alias:

git config --global alias.undo '!git reset --soft HEAD~1'
Enter fullscreen mode Exit fullscreen mode

To undo your last commit you just type:

git undo
Enter fullscreen mode Exit fullscreen mode

Cool, right? You can also combine commands like this:

git config --global alias.shipit '!git add -A && git commit -m'
Enter fullscreen mode Exit fullscreen mode

Now to stage all my files and comitt I just type:

git shipit 'message so relevant that my mother would be proud'
Enter fullscreen mode Exit fullscreen mode

Do you already use aliases in your daily life? Share it in the comments so I can copy it and avoid fatigue!

ps: Did you noticed my custom octocat? Check out the awesome artwork by Zilart

๐Ÿš€

Oldest comments (4)

Collapse
 
negoziator profile image
Lars Christian Schou

Here's my list. I might take some of yours as well ๐Ÿ˜€

One I really appreciate is git ul
Use that everytime I create a new branch and want to upstream it.

[alias]
st = status
ci = commit
cm = commit -m
co = checkout
cp = cherry-pick
br = branch
pr = pull --rebase
develop = checkout develop
master = checkout master
last = log -1 HEAD
unstage = reset HEAD --
staged = diff --cached
prp = !git pull --rebase && git push
ul = push -u origin HEAD
loll = log --graph --decorate --pretty=oneline

Collapse
 
netohog profile image
Neto Hog

Thanks for sharing, Lars!

Your 'git ul' just entered my list of aliases ๐Ÿ˜€

Collapse
 
natalia_asteria profile image
Natalia Asteria

Umm, GitHub isn't Git, sir.

Collapse
 
netohog profile image
Neto Hog

you're absolutely right