Aliases for git

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.

Aliases

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:

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:

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:

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:

Just hit  git print <commit> to display more informations about a commit.

ZSH prompt

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.

 

One Comment

  • Tadas Reply

    I’ve got these:

    [alias]
    st = status
    logg = log –graph –oneline –abbrev-commit –decorate
    cm = commit -m
    co = checkout
    br = branch
    aa = add .
    ps = push

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.