Even if you’re not a developer, when you’re working with open-source projects, you come in contact with git all the time.
Git is our preferred SCM solution and we use it extensively in our open-source and internal projects.
Git is really nice and it allows you to define aliases in your ~/.gitconfig.
Here are some simple aliases I use in my git config:
[alias] st = status ci = commit co = checkout br = branch
Now you should be able to run git st instead of git status. The same for ci, co and br.
Because we do some rebasing in our projects, I have also some aliases in place for that:
[alias] cia = commit --amend pushf = push --force pullf = pull --force rb = rebase rbi = rebase -i rbc = rebase --continue
Logging in git is quite powerful, but you need to specify a lot of different flags to get a nice output.
Check out these aliases:
[alias] logg = log --graph --abbrev-commit --decorate --all --format=format:'%C(bold cyan)%h%C(reset) - %C(yellow)[%ar]%C(reset) %C(white)%s%C(reset)%C(green bold)%d%C(reset) %C(dim white)- %aN%C(reset)' hist = log --pretty=format:'%C(bold cyan)%h%C(reset) - %C(yellow)[%ad]%C(reset) %C(white)%s%C(green bold)%d%C(reset) %C(dim white)- %aN%C(reset)'
Go to a project and hit git logg to see a tree / graph of the full commit history.
You can also run git logg to display a simple but nice version of the commit history.
If you need to get more informations about a blob, tree commit or tag, you’ve to use the cat-file feature, which I can’t remember and therefor I created two new aliases:
[alias] type = cat-file -t print = cat-file -p
Just hit git print <commit> to display more informations about a commit.
If you’re also using zsh and oh-my-zsh, you should really have a look at the powerlevel9k theme, which has a neat prompt for git repos.
We already mentioned that in our zsh: A shell on steroids blog post.