a nasty git alias hack

twitter logo github logo ・1 min read

a nasty git bash alias hack


create a file ~/.bash_aliases

$ cat ~/.bash_aliases 
alias ga="git add ."
alias gc='git commit -m "autocommit"'
alias gd="git diff"
alias gp="git push"
alias gs="git status"

now you can add commit and push with 6 chars

$ ga
$ gc
$ gp


this is a sackable offence in many outfits as it creates meaningless commit messages 😁

twitter logo DISCUSS (12)
markdown guide

If you replace

alias gc='git commit -m "autocommit"'

with just

alias gc='git commit -m'

You could do

gc "Fixed something"

and it would be a timezaver for real projects too


you havent met my mgr have you ? so thanks but "fixed something" would be unacceptable :) it needs to have the JIRA num in it at least


πŸ˜† πŸ‘ Good manager you've got there, Clive. I don't think mine has ever even seen my commit messages, let alone cares about them.

But I think Maurits' point was more that if you don't include a default commit message in the alias, you can save yourself some typing (by shortening git commit -m to gc) while still requiring a message from yourself on the command line.

I started using Zsh as a default shell instead of Bash a few years ago (no real reason besides curiosity) along with the Oh My Zsh framework, and that framework adds a metric shit-ton of git aliases along those lines.

I don't use them these days as I prefer interacting with git directly from my editor, but I tried them out in the beginning and they were fun to use for awhile.

yes your right he is NOT actually recommending the same text for every commit if you read carefully sorry my mistake

and i certainly hope your mgr isnt reading DEVTO ! :)


Why do you recommend not to use in the real world? I don't think there is any issues with this...


Sorry for my ignorance, but what is "mgr"? Manager?

sorry mgr is shorthand for manager most dev mgrs require you to at least put the jira number in any git comment :)

Ahh ok, thanks, I assumed so, but was not sure :P

Classic DEV Post from Oct 15 '18

How to build a Vue CLI plugin

This article describes how to build a simple Vue CLI plugin from scratch and publish it to npm

Clive Da profile image
open source devops & open source webdev & open source sysadmin