Git is simple and powerful, but sometimes its commands and options are getting in the way of my development flow. Fortunately, it does allow easy customization.
First, create a file .gitconfig in your user folder. It is a simple text file with sections and properties. I prefer editing this file to entering individual properties through the git config command.
editor
I usually avoid editing text from the command line and prefer to use a lightweight text editor like Notepad2 or Sublime
[core]
editor = notepad2
command aliases
Here is my day to day workflow using my custom aliases:
// see current state of things
git st
// see very compact log of things
git lg
// normal work: add, modify, delete
// see changes as word differences
git wdiff
// commit to local repo
git done "done and done"
// push all branches to origin
// similar alias for github, bitbucket
git toorigin
// every day before going to stand up I want to see my commits
git standup
Here are the command aliases:
[alias]
st = status -sb
standup = log --pretty=format:'%Cred%h%Creset -%Creset %s %Cgreen(%cD) %C(bold blue)<%an>%Creset' --since='1 week ago' --author gleb
lg = log --pretty=format:'%Cred%h%Creset -%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
wdiff = diff --word-diff=plain
ignored = ls-files --others -i --exclude-standard
amend = !git log -n 1 --pretty=tformat:%s%n%n%b | git commit -F - --amend
done = commit -am
toorigin = push origin --all
togithub = push github --all
tobitbucket = push bitbucket --all
git aliases: the best part
Git is smart enough to suggest aliases in addition to its built-in commands if you misspell something:
$ git s
git: 's' is not a git command. See 'git --help'.
Did you mean one of these?
show
status
st
How cool is this?!
color options
Previous aliases look nice because they use custom colors:
[color]
branch = auto
diff = auto
status = auto
ui = true
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red
new = cyan
[color "status"]
added = yellow
changed = green
untracked = cyan
More information
I keep my .files in a git repo located in my user folder, available on github. Feel free to fork and modify. It is largely based on the repo created by Paul Irish
- I use git-extras to perform all my Git commands from the terminal.
- git-tips is a huge list of useful Git one-liners
- my blog post Git Tips And Tricks