blob: f25ba48c68628be68971672aeeecb3753df8d823 (
plain)
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
|
#!/bin/sh
set -e
git_branch() {
git rev-parse --symbolic-full-name --abbrev-ref HEAD
}
[ -d .git ] || {
echo "error: not a git repository"
exit 1
}
[ -d .idea ] || {
echo "error: not a jetbrains repository"
exit 1
}
PREFETCH_HOOK=.git/hooks/prefetch
CUR_BRANCH=$(git_branch)
TARGET_BRANCH="$CUR_BRANCH"
while getopts b: option
do
case "${option}"
in
b)
TARGET_BRANCH=${OPTARG}
;;
*)
:
;;
esac
done
if [ "$CUR_BRANCH" != "$TARGET_BRANCH" ]; then
echo "new target branch: $TARGET_BRANCH"
fi
git add .
git reset --hard
[ -x "$PREFETCH_HOOK" ] && "./$PREFETCH_HOOK"
git fetch -a dev
if [ "$CUR_BRANCH" != "$TARGET_BRANCH" ]; then
git checkout "$TARGET_BRANCH" --
fi
git reset --hard dev/$TARGET_BRANCH
#git pull dev $TARGET_BRANCH
echo "current branch: $(git_branch)"
|