Skip to content

Commit 85cbeda

Browse files
committed
git-remaster: restore stash when fetch fails
1 parent d078f7b commit 85cbeda

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

git-remaster

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ RSTASH=$(git stash create --include-untracked)
1616

1717
if [[ $RSTASH ]]; then
1818
echo "Stashed $RSTASH"
19+
git stash store -m "Remaster on branch $BRANCH $(date)" "$RSTASH"
1920
git reset --hard
2021
fi
2122

2223
# fetch updates
23-
git fetch --prune --no-tags origin $MASTER
24-
25-
# if not on master branch, check it out, update and return to branch
26-
if [[ $BRANCH != $MASTER ]]; then
27-
git checkout $MASTER
24+
if git fetch --prune --no-tags origin $MASTER; then
25+
# if not on master branch, check it out, update and return to branch
26+
if [[ $BRANCH != $MASTER ]]; then
27+
git checkout $MASTER
28+
git rebase origin/$MASTER --preserve-merges
29+
git checkout -
30+
fi
31+
# rebase changes on top of origin/master
2832
git rebase origin/$MASTER --preserve-merges
29-
git checkout -
3033
fi
3134

32-
# rebase changes on top of origin/master
33-
git rebase origin/$MASTER --preserve-merges
34-
3535
# bring back stash if available, hide errors when empty
3636
if test $RSTASH; then
3737
git stash apply $RSTASH

0 commit comments

Comments
 (0)