Git: Command Line Tricks

23 May 2017 | About a 4 minute read
Tags: Code, developer, DevOps, girlswhocode, git, tech, womenintech

Most of us at this stage will be familiar with Git, the wonderful version control system that makes coding in a team so much easier. You’re probably already familiar with how to pull and commit (and no, that has nothing to do with Tinder), but what you might not know is just how powerful Git can be and all the cool things we can do with it. Below are five of my favourite commands:


You should know that git branch will show you a list of the branches you are tracking, but did you know about git branch -vv ?

While git branch will give you the list of branches and which one you are currently working on, git branch -vv will give you more information, including the SHA and commit message.



Git supports aliases, which means that you can save any lengthy commands as whatever you want to call them.

For example, in the image above, I have saved the command for creating a new branch as simply new, so if I want to create a new branch, all I need to do is type git new <branch name>


Granted, this is hardly the lengthiest command in git, but this could come in handy for things like stash –include-untracked

Which brings us onto our next point



Git stash comes in handy when you need to switch branches but don’t want to commit your work in progress, but it can cause trouble sometimes when it doesn’t stash any untracked files.

To get around this, stash –include-untracked, is your friend.


So, git log is a handy way to give us a brief into the state of our repo. However, from the command line, this doesn’t always look very pretty, or even legible:

There are a bunch of ways you can adjust the colours and display to your liking and the git documentation on pretty formatting can give you a good overview, but one quick way you can improve the appearance is by using git log –graph –decorate, as in the example below:

Spot the difference

It can be really handy sometimes to check in and see how much you’ve changed since your last push to the repo. For this, we call on git diff.

There are many different options you can tack onto your git diff, as you can see here, but in my example above, I have added –minimal, which takes a little more time to try and produce the smallest possible diff.


So there you have a very small selection of things you can do with git. To list them all would require a lot more space than a blog, but thankfully, the good folks over at have taken care of that for you. Hopefully this has given you some useful tricks to try out, and if you have any commands that you particularly like yourself, we’d love to hear about them!

Share this blog post

Related Articles


We’re looking for bright, dynamic people to join our team!

Discover More Roles