1 | #!/bin/bash |
---|
2 | |
---|
3 | set -e |
---|
4 | |
---|
5 | function pause() { |
---|
6 | read -p "$*" |
---|
7 | } |
---|
8 | |
---|
9 | if [ $# -ne 2 ] |
---|
10 | then |
---|
11 | echo "Usage: `basename $0` BRANCH_FROM BRANCH_TO" |
---|
12 | exit 1 |
---|
13 | fi |
---|
14 | |
---|
15 | BRANCH_FROM=$1 |
---|
16 | BRANCH_TO=$2 |
---|
17 | |
---|
18 | echo "Checking out branch $BRANCH_TO..." |
---|
19 | git checkout $BRANCH_TO |
---|
20 | |
---|
21 | echo "Pulling latest changes into $BRANCH_TO..." |
---|
22 | git pull |
---|
23 | |
---|
24 | echo "Checking out branch in question ($BRANCH_FROM)..." |
---|
25 | git checkout $BRANCH_FROM |
---|
26 | |
---|
27 | pause "Rebasing $BRANCH_FROM on top of $BRANCH_TO... OK?" |
---|
28 | git rebase origin/$BRANCH_TO |
---|
29 | |
---|
30 | echo "Checking out branch $BRANCH_TO..." |
---|
31 | git checkout $BRANCH_TO |
---|
32 | |
---|
33 | echo "Pulling latest changes into $BRANCH_TO..." |
---|
34 | git pull |
---|
35 | |
---|
36 | pause "Merging $BRANCH_FROM with $BRANCH_TO... OK? (If there were updates on the previous step, press CTRL+C to abort!)" |
---|
37 | git merge --log --no-ff $BRANCH_FROM |
---|
38 | |
---|
39 | echo "Starting gitk to make sure you like the result..." |
---|
40 | gitk |
---|
41 | |
---|
42 | pause "Push to the origin!? (Press CTRL+C to abort!)" |
---|
43 | git push origin $BRANCH_TO |
---|
44 | |
---|
45 | pause "Proceed with the cleanup? (Press CTRL+C to abort!)" |
---|
46 | git push origin :$BRANCH_FROM |
---|
47 | git branch -d $BRANCH_FROM |
---|
48 | |
---|
49 | echo "Congratulations! Yet another glorious merge succesfully completed!" |
---|
50 | |
---|
51 | exit 0 |
---|