I normally use Git for my personal projects but at work I use Mercurial. While I prefer Git overall, Mercurial has some nice commands that are missing from Git. One particularly useful one is hg out
which prints the changesets in your local repository that are missing from the remote. Here is a simple script which does approximately the same thing for Git:
#!/bin/sh for i in $(git push -n $* 2>&1 \ | awk '$1 ~ /[a-f0-9]+\.\.[a-f0-9]+/ { print $1; }') do git log --oneline $i done
Store it as git-out
somewhere in your PATH and you can use git out
just like a regular Git command.
$ git log origin..master
[assuming your remote you are pushing to is called origin]
January 26, 2011 @ 1:06 am
It also assumes you are pushing from a branch called master and there are no commits to be pushed from other branches. It is also only accurate if you do a git fetch immediately beforehand. The script above has none of these limitations.
January 26, 2011 @ 6:43 am
[…] git-out is a script that emulates hg outgoing quite accurately. It parses on “push -n” output, so it produces accurate output if you need to specify additional arguments to push. […]
December 16, 2014 @ 5:20 am