Auto-update: Tue Jul 30 20:57:45 PDT 2024

This commit is contained in:
sanj 2024-07-30 20:57:45 -07:00
parent 7b89cb187c
commit 9155daf978

22
up
View file

@ -37,12 +37,26 @@ while IFS= read -r repo_path || [[ -n "$repo_path" ]]; do
continue
fi
# Check if 'origin' remote exists
if ! git remote | grep -q '^origin$'; then
echo "Remote 'origin' not found. Attempting to set it up..."
# Try to guess the remote URL based on the directory name
repo_name=$(basename "$repo_path")
remote_url="https://git.sij.ai/sij/$repo_name.git"
git remote add origin "$remote_url"
echo "Added remote 'origin' with URL: $remote_url"
fi
# Get the current branch
current_branch=$(git rev-parse --abbrev-ref HEAD)
# Pull the latest changes from the repository
echo "Pulling from $current_branch branch..."
git pull origin "$current_branch"
if ! git pull origin "$current_branch"; then
echo "Failed to pull from origin. The remote branch might not exist or there might be conflicts."
echo "Skipping further operations for this repository."
continue
fi
# Add changes to the Git index (staging area)
echo "Adding all changes..."
@ -58,7 +72,11 @@ while IFS= read -r repo_path || [[ -n "$repo_path" ]]; do
# Push changes to the remote repository
echo "Pushing all changes..."
git push origin "$current_branch"
if ! git push origin "$current_branch"; then
echo "Failed to push changes. The remote branch might not exist."
echo "Creating remote branch and pushing..."
git push -u origin "$current_branch"
fi
fi
echo "Update complete for $repo_path!"