-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitvb-remote-rebase
executable file
·60 lines (45 loc) · 1.17 KB
/
gitvb-remote-rebase
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
set -e
GITVB_HOME="./.git/.gitvb-v0"
MAIN_BRANCH="${MAIN_BRANCH:-main}"
if [ ! -z "$(git diff --staged)" ]; then
echo "there are staged changes. exiting."
exit 1
fi
if [ "$(git branch --show-current)" != "$MAIN_BRANCH" ]; then
echo "you are not on the main branch: $MAIN_BRANCH"
exit 1
fi
if [ "$1" == "" ]; then
echo "usage: gitvb-remote-rebase <branch>"
exit 1
fi
branch="$1"
if [ -f "$vbFilePath" ]; then
echo
echo "cannot remote rebase '$branch' since it's picked"
echo "unpick it first, or use gitvb-resync"
echo
exit 2
fi
echo "remote-rebase: wip stash"
gitvb-wip remote-base
echo "remote-rebase: fetching..."
git fetch --quiet
echo "remote-rebase: checking out '$branch'"
git checkout $branch
echo "remote-rebase: pulling..."
git pull
echo "remote-rebase: rebasing..."
git rebase "origin/$MAIN_BRANCH"
echo "remote-rebase: pushing..."
git push --force-with-lease
echo "remote-rebase: going back to $MAIN_BRANCH"
git checkout $MAIN_BRANCH
echo "remote-rebase: undo wip stash"
gitvb-wip-undo remote-base
echo
echo "successfully rebased $branch"
echo " you can pick it by running"
echo " $ gitvb-pick $newBranch"
echo