mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 15:36:21 -04:00
24 lines
430 B
Bash
Executable file
24 lines
430 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
COMMIT_MESSAGE='Initial commit'
|
|
|
|
if [ "$1" == "-m" ]; then
|
|
COMMIT_MESSAGE=$2
|
|
shift; shift
|
|
fi
|
|
|
|
gitdirexists(){
|
|
if [ -d ".git" ]; then
|
|
echo ".git directory already exists, aborting"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
dir=$(test -z "$*" && echo "." || echo "$*")
|
|
mkdir -p "$dir" \
|
|
&& cd "$dir" \
|
|
&& gitdirexists \
|
|
&& git init \
|
|
&& git add . \
|
|
&& git commit --allow-empty -m "$COMMIT_MESSAGE"
|