Skip to content

Commit 41e3ad0

Browse files
committed
minor: introduce fast-forward-merge.sh
1 parent 181230c commit 41e3ad0

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

fast-forward-merge.sh

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
3+
# GitHub does not support fast-forward merge.
4+
# This script is intended to simplify merge of Pull Requests to keep history linear (fast-forwarded)
5+
# All Pull Requests from GitHub to our project has to be applied to our code by this script.
6+
7+
set -e
8+
9+
if [ $# -eq 0 ]
10+
then
11+
echo "$(basename "$0") FORK_USER_NAME USER_BRANCH
12+
example:
13+
14+
./$(basename "$0") konstantinos issue73
15+
"
16+
exit 0;
17+
fi
18+
19+
GIT_REPO=contribution
20+
FORK_USER_NAME=$1
21+
USER_BRANCH=$2
22+
REPO=${FORK_USER_NAME}-fork
23+
LOCAL_USER_BRANCH=${FORK_USER_NAME}-${USER_BRANCH}
24+
25+
echo "adding remote ..."
26+
git remote add ${REPO} https://github.com/${FORK_USER_NAME}/${GIT_REPO}.git
27+
git fetch ${REPO}
28+
29+
echo "creating local branch ..."
30+
git checkout -b ${LOCAL_USER_BRANCH} ${REPO}/${USER_BRANCH}
31+
32+
echo "rebasing over master ..."
33+
git rebase master
34+
35+
echo "merge to master ..."
36+
git checkout master
37+
git merge ${LOCAL_USER_BRANCH} --ff-only
38+
39+
echo "removing local branch ..."
40+
git branch -D ${LOCAL_USER_BRANCH}
41+
42+
echo "removing remote ..."
43+
git remote rm ${REPO}

0 commit comments

Comments
 (0)