Thursday, January 31, 2013 » Improvement Productivity Tools Git Github

Power up the Git Commandline

Just showing off some tools and commands everyone should know.

Github in the shell ΒΆ

One of the coolest tools around for working with github in the shell is hub. It is a wrapper around git that extends it with a few very useful functions that make interacting with github a whole lot easier.

Some teasers:

Clone new repos: ΒΆ

# gh clone mfussenegger/dotfiles
---> gh clone git://github.com/mfussenegger/dotfiles.git

Create pull requests: ΒΆ

# gh pull-request -b upstream:master -h mfussenegger:feature

Merge pull requests: ΒΆ

# gh merge https://github.com/someoneelse/repo/pull/9283

There is many more, so make sure to check out the Hub documentation.

git-wtf ΒΆ

git-wtf is a script I found in Zach Holman’s dotfiles repo. It’s pretty neat to get a quick overview on the repo’s current state.

Description from the git-wtf help:

git-wtf displays the state of your repository in a readable, easy-to-scan
format. It's useful for getting a summary of how a branch relates to a remote
server, and for wrangling many topic branches.

git-wtf can show you:
- How a branch relates to the remote repo, if it's a tracking branch.
- How a branch relates to integration branches, if it's a feature branch.
- How a branch relates to the feature branches, if it's an integration
branch.

git-wtf is best used before a git push, or between a git fetch and a git
merge. Be sure to set color.ui to auto or yes for maximum viewing pleasure.
EOS

git-wtf

git-up ΒΆ

Also found in Zach’s repo:

Like git-pull but show a short and sexy log of changes immediately after merging (git-up) or rebasing (git-reup).

git-up

the power of the alias ΒΆ

A quick list of my favorites:

In gitconfig:

killbranches = !git branch --merged | grep -v '^*' \
               | grep -v master | xargs git branch -d 2> /dev/null

As shell aliases (these are zprezto defaults):

alias gwD='git diff --no-ext-diff --word-diff'
alias gws='git status --ignore-submodules=${_git_status_ignore_submodules} --short'
alias gl='git log --topo-order --pretty=format:${_git_log_medium_format}'
alias gld='git log --topo-order --stat --patch --full-diff --pretty=format:${_git_log_medium_format}'

That’s about it. Hope you learned something new!