Published at
Updated at
Reading time
1min
This post is part of my Today I learned series in which I share all my web development learnings.

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

When you're working with git, you deal with several local branches. To overview 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 from now on.

If you enjoyed this article...

Join 5.5k readers and learn something new every week with Web Weekly.

Web Weekly — Your friendly Web Dev newsletter
Reply to this post and share your thoughts via good old email.
Stefan standing in the park in front of a green background

About Stefan Judis

Frontend nerd with over ten years of experience, freelance dev, "Today I Learned" blogger, conference speaker, and Open Source maintainer.

Related Topics

Related Articles