Now that I don’t use Mercurial at work anymore, I’ve found that despite its shortcomings (
hg status taking 10+ seconds?!) it has some few nice features. One of those is
hg outgoing, which shows you which changesets you are going to send to remote repo in your next push. A quick glance at this list will typically ensure that everything is in order, or allow to amend some commits before making them public.
In Git you can do the similar by applying a filter to
origin is most often the remote you want to compare against, the
master branch is typically not the one where most of development takes place. So if we want to create a
git outgoing command, we would rather check what the current branch is and compare it with its remotely tracked equivalent:
Simply naming this script
git-outgoing and making it executable somewhere within your
/usr/bin) will make the
git outgoing command available:
There are few untold assumptions here, like the fact that branch names must match on both local and remote repo. If you find yourself breaking those, then you’re probably better to just use
git log directly.
I think the assumption about branch names isn’t required is you use
… nevermind, you still need to determine the remote branch name :)
Yeah, that’s the assumption: the script uses local branch name to determine remote branch name.
Now, you could improve it by getting the info on what local branch pushes to what remote branch. I don’t how to do that, short of parsing the output of
git remote show origin which is pretty much in natural language… So I’ll leave it as exercise for the reader ;-)