Python-Git recent v1.0.3: See your latest local git branches, formatted real fancy

icon
Latest Release: v1.0.3

git-recent

Type git recent to see your latest local git branches

Usage

git recent

Optionally, add -n<int> to see the most recent <n> branches

git recent -n5

git-recent screenshot

If you're a Windows user, you need to use Git Bash or similar shell in order to effectively use this utility.

Installation

You can add the git-recent location to your path (e.g. add the directory to your PATH environment or copy git-recent into an existing included path like /usr/local/bin or ~/bin/).

You can use also npm to install the global binary:

npm install --global git-recent

On Mac, you can install with homebrew:

brew install git-recent

If you like this you may also be interested in...

  • git open - Open the repo website in your browser
  • diff-so-fancy - Making the output of git diff so fancy

License

Copyright Paul Irish. Licensed under MIT.

Changelog

  • 2016-05-16 - added to paulirish/dotfiles
  • 2016-08-05 - released in standalone repo and published to npm

Comments

  • error: unknown option `color=always'
    error: unknown option `color=always'

    Mar 3, 2018

    This affects OS X 10.11 and below.

    ==> brew test git-recent --verbose
    ==> FAILED
    Testing git-recent
    /usr/bin/sandbox-exec -f /tmp/homebrew20180303-48976-qdimti.sb /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/bin/ruby -W0 -I /usr/local/Homebrew/Library/Homebrew -- /usr/local/Homebrew/Library/Homebrew/test.rb /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/git-recent.rb --verbose
    ==> git init
    Initialized empty Git repository in /private/tmp/git-recent-test-20180303-48977-s6zris/.git/
    ==> git recent
    error: unknown option `color=always'
    usage: git for-each-ref [<options>] [<pattern>]
       or: git for-each-ref [--points-at <object>]
       or: git for-each-ref [(--merged | --no-merged) [<object>]]
       or: git for-each-ref [--contains [<object>]]
    
        -s, --shell           quote placeholders suitably for shells
        -p, --perl            quote placeholders suitably for perl
        --python              quote placeholders suitably for python
        --tcl                 quote placeholders suitably for Tcl
    
        --count <n>           show only <n> matched refs
        --format <format>     format to use for the output
        --sort <key>          field name to sort on
        --points-at <object>  print only refs which points at the given object
        --merged <commit>     print only refs that are merged
        --no-merged <commit>  print only refs that are not merged
        --contains <commit>   print only refs which contain the commit
    
    Reply
  • Add as zsh plugin like git-open ?
    Add as zsh plugin like git-open ?

    Dec 17, 2018

                                                                                                                                                                                                           
    Reply
  • customizable colors would be neat
    customizable colors would be neat

    Jun 21, 2019

    https://github.com/paulirish/git-recent/blob/19853911344cecc99e6bfdbaf0e076080bc44b60/git-recent#L41

    In Powershell's default color scheme the blue author name on blue background is not easy to read.

    image

    It would be helpful if there were an easy way to change the color.

    Reply
  • Why `%(upstream:track)`?  ... I'm intrigued!  😀
    Why `%(upstream:track)`? ... I'm intrigued! 😀

    Jun 24, 2019

    It's not wrong, but I was just wondering about the purpose of this line:

    %(color:bold yellow)%(upstream:track)%(color:reset)
    

    The %(upstream:track) directive is only relevant if you have two local branches, one of which is the upstream for the other one... put differently: it has no relevance for remote-tracking branches.

    Like I said: nothing wrong with it, but I'm intrigued by the workflow where you have a local branch with an upstream local... ie. what kind of git workflow would give rise to this use-case?

    Reply
  • Accept count as '-X' as well, add usage and error handling
    Accept count as '-X' as well, add usage and error handling

    Mar 20, 2020

    Also make shellcheck happy.

    Reply
  • Add zsh plugin
    Add zsh plugin

    Jul 7, 2020

    closes #18

                                                                                                                                                                                                           
    Reply
  • Tag releases
    Tag releases

    Jan 16, 2017

    Nice tool! Only just found it. 😮

    I've submitted a PR at homebrew/homebrew-core#8979 to get it brew installable - this issue is in anticipation of being told the release needs to be git tagged (or otherwise have the version number in it).

    Might that be possible? 🙂

    Reply
  • Table format broken on Windows
    Table format broken on Windows

    Aug 11, 2016

    At the expense of being the odd one out around here on Windows, I installed git-recent on my system and already love it. It works perfectly overall, except for one minor thing. column messes up the table layout when there are control chars in any except the last column. For example:

    git-recent

    If I go and temporarily remove the coloring from the refname like so:

      format="\
    - %(HEAD) %(color:yellow)%(refname:short)%(color:reset)|\
    + %(HEAD) %(refname:short)|\
      %(color:bold red)%(objectname:short) %(color:bold green)(%(committerdate:relative)) %(color:blue)%(authorname) %(color:reset)%(color:yellow)%(upstream:track)%0a\
    -   %(color:black) %(color:reset)|%(contents:subject)%0a\
    +    |%(contents:subject)%0a\
        |"
    

    Then columns do line up properly and match the screenshot on the README:

    git-recent-2

    If I have to guess, this seems to be more of a column problem than a git recent problem, but I though I bring it up in case I'm missing something. If anyone can point me in the right direction I can make a PR attempt.

    Reply
  • Fix typo
    Fix typo

    Aug 5, 2016

    Fixes a small typo

                                                                                                                                                                                                           
    Reply
  • Handle new git behavior requiring count parameter
    Handle new git behavior requiring count parameter

    Jun 14, 2019

    @paulirish

    I ran into an issue today with git-recent where it was giving me an error:

    error: option `count' expects a numerical value
    

    I believe my build environment upgraded git with a new constraint on the --count parameter, as shown in this commit: https://github.com/git/git/commit/20aa7c594fbc2e36476daae2f53d7c020306c62c#diff-15a33e465ac44642a84b00186e663b7f

    Passing a count of 0 appears to behave the same way it used to when the count was missing. It does still render some strange (null) values (with or without the -n parameter), but I suspect that's yet another fix that may need to happen in addition to this one.

    Reply
  • Option to show commit descriptions
    Option to show commit descriptions

    Sep 2, 2016

    For when someone commits with a "WIP" message, just to add an essay description.

    Reply
  • Workaround for broken format on Windows
    Workaround for broken format on Windows

    Aug 27, 2016

    Before

    1-before

    After

    2-after

    Essentially, this trades yellow refnames with proper alignment. Once column is fixed, this can then be burned to ashes. This only affects Windows.

    Ref. #8

    Reply
  • show ↑↓ information
    show ↑↓ information

    Aug 6, 2016

    null

                                                                                                                                                                                                           
    Reply
  • Add count parameter
    Add count parameter

    Nov 19, 2016

    Added a count parameter so users could see the last n ~~commits~~ branches.

    Completely optional argument, see below:

    usage:

    git recent default behavior git recent 0 default behavior git recent 5 last 5 ~~commits~~ branches returned, instead of all of them git recent ( n > number of total branches ) default behavior

    ...and so on.

    Reply
  • git-recent's output does not highlight
    git-recent's output does not highlight

    Nov 3, 2017

    I don't know why, my iterm2 can't highlight the git-recent's output.

    Reply
  • Windows compatibility
    Windows compatibility

    Aug 8, 2016

    Hi @paulirish

    I have installed the module on my machine running Windows 10 and got the following: git-recent I think something is missing while running it on the Windows.

    Reply