tj.git-extras/bin/git-setup
Jianjin Fan 6df9673936 Allow empty initial commit when setup repo.
When hit `git setup` in an empty directory, it doesn't create a commit. But often we need an empty initial commit for future rebasing and reseting, etc. Fixes #318.
2015-02-20 12:25:25 +08:00

17 lines
327 B
Bash
Executable file

#!/usr/bin/env bash
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 'Initial commit'