Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Created October 12, 2021 14:56
Show Gist options
  • Select an option

  • Save KyMidd/95afb1c677107ea322ea7484a74361ee to your computer and use it in GitHub Desktop.

Select an option

Save KyMidd/95afb1c677107ea322ea7484a74361ee to your computer and use it in GitHub Desktop.
# If cloned repo is empty, initialilze main branch
initRepo=
if echo "$gitCloneResults" | grep -q "You appear to have cloned an empty repository"; then
echo "Empty repo detected, initializing main branch"
initRepo=true
cd $repo
git init
git checkout -b main
git commit --allow-empty -m "SOP-22353 Initialize repo"
# Attempt git push, check for archived to safely catch
gitPushResults=
gitPushResults=$(git push --force --set-upstream origin main 2>&1 || true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment