forked from MarkLodato/visual-git-guide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish
More file actions
executable file
·29 lines (29 loc) · 710 Bytes
/
publish
File metadata and controls
executable file
·29 lines (29 loc) · 710 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
if [ $# -eq 0 ]; then
echo "USAGE: $0 <files>" >&2
exit 1
fi
if ! git diff --quiet; then
echo >&2
echo "ERROR: working tree is dirty; aborting..." >&2
echo >&2
exit 2
fi
if ! git diff --quiet --cached; then
echo >&2
echo "ERROR: index is dirty; aborting..." >&2
echo >&2
exit 2
fi
HEAD=`git symbolic-ref HEAD`
SHA=`git rev-parse HEAD`
git symbolic-ref HEAD refs/heads/gh-pages || exit $?
mv .git/index .git/index.old || exit $?
git add -f "$@" || exit $?
if git diff --quiet --cached; then
echo "nothing to commit..."
else
git commit -m "build from $SHA" || exit $?
fi
git symbolic-ref HEAD "$HEAD" || exit $?
mv .git/index.old .git/index || exit $?