-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseperate-git.bash
More file actions
31 lines (25 loc) · 860 Bytes
/
seperate-git.bash
File metadata and controls
31 lines (25 loc) · 860 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
#!/usr/bin/env bash
# Ensure that we dont inadvertantly checkin any node node_modules
# or the file that we use to track our local_git repository
if [ ! -f .gitignore ]; then
cat > .gitignore << ENDIGNORE
node_modules
.local_git
ENDIGNORE
fi
# Look inside of our post to load up where the remote
# is configured, bail if not set
REMOTE=$(awk '/^remote:/ {print $2}' index.md |head -n 1)
if [ -z "${REMOTE}" ]; then
echo remote is not defined in the front matter of index.md
exit 1
fi
LOCAL_GIT=$(cat .local_git 2> /dev/null)
# If blank or doest exist checkout the bare repository
if [ -z "${LOCAL_GIT}" ] || [ ! -d "${LOCAL_GIT}" ]; then
LOCAL_GIT=$(mktemp -d)
echo Pulling down remote git repository into $LOCAL_GIT
git clone --bare --progress $REMOTE $LOCAL_GIT
echo $LOCAL_GIT > .local_git
fi
git --git-dir=${LOCAL_GIT} --work-tree=. $@