-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathgit-baseless-commit
More file actions
executable file
·35 lines (29 loc) · 893 Bytes
/
git-baseless-commit
File metadata and controls
executable file
·35 lines (29 loc) · 893 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
30
31
32
33
34
35
#!/bin/sh
#
# WHY!?
#
# The purpose of this command is to allow me to create a snapshot of a
# tree without history. My primary use for such a thing is to
# distribute large generated documentation sets as gh-pages for
# github.
#
msg="$@"
if [ -z "$msg" ]
then
echo "Usage: git baseless-commit my awesome commit message"
exit 1
fi
thisbranch=`git symbolic-ref HEAD`
oldhead=`git rev-parse HEAD`
if [ $thisbranch != refs/heads/gh-pages ]
then
echo "You're currently on a branch called $thisbranch"
echo "If you're OK destroying that branch, hit enter, otherwise hit ^C"
read all_about_it
fi
tree=`git write-tree`
commit=`echo "$msg" | git commit-tree $tree`
git symbolic-ref -m "git baseless-commit" HEAD $thisbranch
git reset --hard $commit
echo "If you messed up and destroyed something on accident, you can"
echo "still get your old head back: $oldhead"