Created
October 12, 2021 14:56
-
-
Save KyMidd/95afb1c677107ea322ea7484a74361ee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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