How I setup my ~/.gitconfig

Because it is such an important part of my git workflow and I always forget

me@jaykilleen.com wrote this about 7 years ago and it was last updated about 7 years ago.


← Back to the Posts

You can add shortcuts to your ~/.gitconfig file. I get sick, well not sick, but I always make typos when writing git status or git push origin master and other common commands.

I'd prefer things like

git s for git status
git aa for git add .
git c for git commit -m so I can git c "WIP 20160216"

So here is my list of aliases that I add to my ~/.gitconfig file.

I also add alias gitmod="nano ~/.gitconfig"; echo "gitmod to modify your .gitconfig" to my .bashrc file so I can easily modify the gitconfig.


[color]
  ui = true
[user]
  name = jaykilleen
  email = me@jaykilleen.com
[alias]
  pom = push origin master
  pod = push origin develop
  a = add
  c = commit -m
  s = status
  aa = !git add -u && git add . && git status
  b = branch
  co = checkout
  deploy = !git push origin develop && git push origin master && cap production deploy
  unstage = reset HEAD --
  last = log -1 HEAD
  aliases = !git config --list | grep ^alias\\. | cut -c 7- | grep -Ei --color

aliases does some magic I don't know about but just lists all the aliases you have set so that you can git aliases into bash while you are learning your shortcuts.

If you are using Git Bash then you will need to swap nano for notepad or your favourite text editor like Atom or Sublime.

Also grep is not available on GitBash so swap aliases out for alias = config --get-regexp ^alias\\. which will just list all your aliases out to the command prompt with alias. appended.