Skip to content

Commit 32b3545

Browse files
committed
Stashing of files only if there are something to stash
1 parent 6846b78 commit 32b3545

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea/

git/branch_update.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,29 @@
22
clear
33

44
CURRENT=$(git name-rev --name-only HEAD)
5+
CHANGES=$(git status -su | wc -l)
56

7+
# sync with another branch
68
BRANCH="master"
79
if [ "$1" = "-b" ] && [ -n "$2" ];
810
then
911
BRANCH="$2"
1012
fi
1113

12-
git stash
14+
# is there something for add to stage?
15+
if [ "$CHANGES" -ne "0" ];
16+
then
17+
git stash
18+
fi
19+
1320
git checkout "$BRANCH"
1421
git pull
1522
git checkout "$CURRENT"
1623
git merge "$BRANCH" -m "Update $CURRENT from $BRANCH"
17-
git stash pop
24+
25+
if [ "$CHANGES" -ne "0" ];
26+
then
27+
git stash pop
28+
fi
1829

1930
git status

0 commit comments

Comments
 (0)