This tool helps create typical revisions (e.g. master..@
), so that you
don’t have to.
For example, if you want to quickly see the commits of the current branch, you can do the following:
git log --oneline master..@
But what if your current branch is not based on master, but say "development"?
You can type development..@
, but it gets tedious to do this for every branch.
You could of course configure the upstream tracking branch of you current branch, and then you can just do:
git log --oneline @{upstream}..@
That’s if you have configured the upstream tracking branch.
git-smartlist
can figure out what revision you would want with the
from-upstream
option:
git smartlist log from-upstream
Then you can create an alias for that:
git config --global alias.ls 'smartlist log from-upstream'
In order so you don’t have to keep track of all this, or type anything,
git-smartlist
allows you to just do:
git ls
There are five shorthands that git smartlist
can help with.
Simply copy the script anywhere in your '$PATH' and make it
executable, or run make install
which will install it by default to
your '~/bin/' directory (make sure it’s in your '$PATH').
The best way to use git smartlist
is to setup aliases to the different modes,
for example, git lb
would be the equivalent of git smartlist log branches
.
First you will need a good log alias, for example 'lg':
git config --global alias.lg 'log --oneline --decorate --boundary --graph'
Then you can add the following to your configuration (git config --global --edit
):
[alias] ls = smartlist lg specific lm = smartlist lg from lc = smartlist lg from-upstream la = smartlist lg all lb = smartlist lg branches ln = smartlist lg negate-upstreams
You can pick any name you want, and only the modes you need, but the two I use the most are:
git ls # shows only the commits of the current branch git lb # shows the commits from all the local branches git lb fc/ # shows the commits from the local branches that start with fc/
This mode is basically saying: show me this specific branch/branches.
By default, it’s the equivalent of:
$ git smartlist echo specific => @{upstream}..@
If you specify a branch:
$ git smartlist echo specific feature-a => feature-a@{upstream}..feature-a
However, if more than one branch is specified:
$ git smartlist echo specific next feature-a => next feature-a --not $merge_base
So, basically it’s a mixture of from-upstream
and branches
.
By default this mode is the equivalent of:
$ git smartlist echo branches => --branches --not $merge_base
However, multiple branches can be specified
$ git smartlist echo branches next feature-a => next feature-a --not $merge_base
Prefixes and namespaces can be specified too:
$ git smartlist echo branches fc/ => --branches=fc/ --not $merge_base
By default this mode is the equivalent of:
$ git smartlist echo from => master..@
But you can specify the branch:
$ git smartlist echo from feature-a => master..feature-a
You can also specify the starting point:
$ git smartlist echo from feature-a next => next..feature-a
By default this mode is the equivalent of:
$ git smartlist echo from-upstream => @{upstream}..@
If there’s no upstream configured, master
is used by default.
You can also specify the branch:
$ git smartlist echo from-upstream feature-a => feature-a@{upstream}..feature-a
git smartlist
can be configured globally, or per repository.
Whether to use the merge-base functionality. If not set
the branches
subcommand would simply do --branches
.
Default: true