#!/bin/bash # http://stackoverflow.com/a/37730085/12916 if [ $# -ge 1 ] then files="$@" else files=* fi for r in $files do echo considering $r if [ -f $r/pom.xml ] && egrep -q '(HEAD|master|[$][{]scmTag[}])' $r/pom.xml then cd $r echo "====== $r =====" git pull --ff-only git log --merges $(git log --reverse --ancestry-path --pretty=%H $(git describe --abbrev=0 HEAD)..HEAD | head -1)...HEAD cd .. fi done