Last Updated: February 25, 2016
· jacaetevha

Git peeking


I can't take credit for these functions, but I love 'em. They were actually written by Clint Modien and posted on Stack Overflow.

These Bash or Zsh functions will allow you to peek into Git to see what is going to happen.

There are two functions you will typically use, grin and grout: git remote incoming (what's going to come down the wire to you) and git remote outgoing (what are you going to push up the wire).

It's simple and fast.

function parse_git_branch {
  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
function gd2 { 
    echo branch \($1\) has these commits and \($2\) does not 
    git log $2..$1 --no-merges --format='%h | Author:%an | Date:%ad | %s' --date=local
function grin {
    git fetch origin master
    gd2 FETCH_HEAD $(parse_git_branch)
function grout {
    git fetch origin master
    gd2 $(parse_git_branch) FETCH_HEAD