mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
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.
17 lines
327 B
Bash
Executable file
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'
|