Update: 2025-05-30 05:34:25
This commit is contained in:
parent
8895255af2
commit
1a69c9d223
2 changed files with 129 additions and 10 deletions
|
@ -93,7 +93,7 @@ fi
|
|||
# ────────────────
|
||||
if ! git remote get-url "$GIT_REMOTE_NAME" &>/dev/null; then
|
||||
info "Creating GitHub repository '$REPO_NAME'..."
|
||||
gh repo create "$REPO_NAME" --public --source=. --remote="$GIT_REMOTE_NAME" --push || error "Failed to create GitHub repo"
|
||||
gh repo create "$REPO_NAME" --public --source=. --remote="$GIT_REMOTE_NAME" || error "Failed to create GitHub repo"
|
||||
else
|
||||
info "Remote '$GIT_REMOTE_NAME' already set to: $(git remote get-url $GIT_REMOTE_NAME)"
|
||||
fi
|
||||
|
@ -110,18 +110,14 @@ else
|
|||
fi
|
||||
|
||||
# ────────────────
|
||||
# Push and Auto-Set Upstream If Needed
|
||||
# Final Push — Always Push, Even If No Upstream
|
||||
# ────────────────
|
||||
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
|
||||
|
||||
if git status 2>&1 | grep -q "no upstream"; then
|
||||
info "Setting upstream for '$BRANCH_NAME' to '$GIT_REMOTE_NAME'..."
|
||||
if ! git config --get branch."$BRANCH_NAME".remote &>/dev/null; then
|
||||
info "No upstream detected. Setting upstream and pushing..."
|
||||
git push -u "$GIT_REMOTE_NAME" "$BRANCH_NAME" || error "Failed to push and set upstream"
|
||||
else
|
||||
if git status | grep -q "Your branch is ahead"; then
|
||||
info "Pushing to GitHub..."
|
||||
git push "$GIT_REMOTE_NAME" "$BRANCH_NAME" || error "Push failed"
|
||||
else
|
||||
info "No push needed. Everything is up to date."
|
||||
fi
|
||||
info "Pushing to remote '$GIT_REMOTE_NAME'..."
|
||||
git push "$GIT_REMOTE_NAME" "$BRANCH_NAME" || error "Push failed"
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue