Published at
Updated at
Reading time
1min

This post is part of my Today I learned series in which I share all my learnings regarding web development.

Today I came across How To Make Life Easier When Using Git by Shane Hudson. The article shares lots of useful git tricks, and one particularly caught my eye.

When you're working with git, you'll deal with several local branches. To get an overview of all the branches, you can use git branch -l.

$ git branch -l
  JonUK/master
  adding-draw.io
  fix-contributors
  fix-puppeteer
* master
(END)

I learned that the branch command also provides two other flags that can come in handy. git branch -v shows you the list of branches, including their last commit.

$ git branch -v
  JonUK/master     6fce128 Used an IIFE for better browser compatibility
  adding-draw.io   7351a8c draw.io added to helper library
  fix-contributors 75da189 Set github access token to maybe avoid rate limiting
  fix-puppeteer    a2b633b Fix headless chrome on zeit
* master           a04c5bb Update desc of css arrows
(END)

And git branch -vv even goes further and shows you the last commit plus a possibly available tracked remote branch. 😲

$ git branch -vv
  JonUK/master     6fce128 Used an IIFE for better browser compatibility
  adding-draw.io   7351a8c draw.io added to helper library
  fix-contributors 75da189 Set github access token to maybe avoid rate limiting
  fix-puppeteer    a2b633b Fix headless chrome on zeit
* master           a04c5bb [origin/master] Update desc of css arrows
(END)

That's pretty cool, and I'll switch my workflow from using git branch -l to using git branch -vv in the future.

Related Topics

Related Articles