Skip to content

Instantly share code, notes, and snippets.

@schnell18
Created December 4, 2013 05:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save schnell18/7782606 to your computer and use it in GitHub Desktop.
Save schnell18/7782606 to your computer and use it in GitHub Desktop.
Bash script to determine if current branch need rebase changes from the integration branch.
#!/bin/bash
# Bash script to determine if current branch(default HEAD)
# need rebase the changes from the integration
# branch(default master)
# Author: Justin Zhang <fgz@qad.com>
# Created: 2013-12-04
#
# Usage:
# check_rebase.sh [current branch] [integration branch]
#
trg=$1
itg=$2
if [[ -z $trg ]]; then
trg=HEAD
fi
if [[ -z $itg ]]; then
itg=master
fi
ret=$(git rev-list $trg..$itg)
if [[ -z $ret ]]; then
echo "You have no need to rebase."
else
echo "You need rebase to absorb the following changes:"
for r in $ret
do
echo $r
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment