create-git-repo.sh: fix amend error if there's no branch checked out

In this case, `git commit --amend` fails.

The state of a .git repo existing without a branch being checked out
can be reached through the following sequence of events (which I just
seem to have triggered):
1. The script calls `git init`
2. The user interrupts the script before `git commit` is finished
This commit is contained in:
Erik Arvstedt 2022-08-28 17:52:47 +02:00
parent d9eecb7d4c
commit 67a573dae8
No known key found for this signature in database
GPG Key ID: 33312B944DD97846

View File

@ -4,7 +4,7 @@
cd "$scriptDir/.."
amend=--amend
if [[ ! -e .git ]]; then
if [[ ! -e .git ]] || ! git rev-parse HEAD 2>/dev/null; then
git init
amend=
fi