From e82a3d217c8294859d8023fdbd17cb080eb3ff40 Mon Sep 17 00:00:00 2001 From: Roman Ivanov Date: Sun, 23 Mar 2014 16:04:04 -0700 Subject: [PATCH] script to make linear history (fast forward) in git --- fast-forward-merge.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 fast-forward-merge.sh diff --git a/fast-forward-merge.sh b/fast-forward-merge.sh new file mode 100755 index 000000000..c6983d01b --- /dev/null +++ b/fast-forward-merge.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +if [ $# -eq 0 ] + then + echo "$(basename "$0") GIT_REPO FORK_USER_NAME USER_BRANCH +example: + + ./$(basename "$0") checkstyle konstantinos issue73 +" + exit 0; +fi + +GIT_REPO=$1 +FORK_USER_NAME=$2 +USER_BRANCH=$3 +REPO=$FORK_USER_NAME-fork +LOCAL_USER_BRANCH=$FORK_USER_NAME-$USER_BRANCH + +echo "adding remote ..." +git remote add $REPO https://github.com/$FORK_USER_NAME/$GIT_REPO.git +git fetch $REPO + +echo "creating local branch ..." +git checkout -b $LOCAL_USER_BRANCH $REPO/$USER_BRANCH + +echo "rebasing over master ..." +git rebase master + +echo "merge to master ..." +git checkout master +git merge $LOCAL_USER_BRANCH + +echo "removing local branch ..." +git branch -D $LOCAL_USER_BRANCH + +echo "removing remote ..." +git remote rm $REPO