-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathpush
More file actions
executable file
·29 lines (22 loc) · 722 Bytes
/
push
File metadata and controls
executable file
·29 lines (22 loc) · 722 Bytes
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
#!/bin/bash
set -e
MAIN="${MAIN:-main}"
if ! git rev-parse --git-dir > /dev/null 2>&1; then
echo 'This is not a git repository.'
exit 1
fi
if [ "`git rev-parse --abbrev-ref HEAD`" == "$MAIN" ]; then
echo 'Rename the branch first. You were about to push your $MAIN branch.'
exit 1
fi
if [[ `git status --porcelain` ]]; then
echo 'WARNING! Your branch has uncommitted changes, consider "commit" or "clean".'
fi
if (! git remote | grep --fixed-strings --line-regexp --quiet 'upstream') then
echo 'Push only works when you have an upstream; consider "save" or "publish".'
exit 1
fi
git fetch upstream
git rebase upstream/$MAIN
#git diff upstream/$MAIN
git push -f origin `git rev-parse --abbrev-ref HEAD`