58 lines
1.5 KiB
Bash
58 lines
1.5 KiB
Bash
#!/bin/bash
|
|
|
|
# This script will initialize a Git repository and push your code to your Gitea server.
|
|
#
|
|
# HOW TO RUN THIS SCRIPT:
|
|
# 1. Open the Terminal in your development environment.
|
|
# 2. Type the following command and press Enter:
|
|
# bash push-to-gitea.sh
|
|
#
|
|
|
|
# Stop the script if any command fails
|
|
set -e
|
|
|
|
echo "Step 1: Initializing Git repository..."
|
|
# Check if a .git directory already exists
|
|
if [ -d ".git" ]; then
|
|
echo "Git repository already initialized."
|
|
else
|
|
git init -b main
|
|
echo "Repository initialized."
|
|
fi
|
|
|
|
echo "Step 2: Adding all files to the repository..."
|
|
git add .
|
|
echo "Files added."
|
|
|
|
echo "Step 3: Creating the first commit..."
|
|
# Check if a commit already exists to avoid errors on re-run
|
|
if git rev-parse -q --verify HEAD; then
|
|
echo "A commit already exists. Skipping commit."
|
|
else
|
|
git commit -m "Initial commit of EstimateFlow project"
|
|
echo "Initial commit created."
|
|
fi
|
|
|
|
|
|
echo "Step 4: Connecting to your Gitea server..."
|
|
# The URL for your Gitea repository
|
|
GITEA_URL="https://git.serfaty.co/admin/estimation-flow.git"
|
|
|
|
# Check if the 'origin' remote already exists
|
|
if git remote get-url origin > /dev/null 2>&1; then
|
|
echo "Remote 'origin' is already configured."
|
|
# Optional: update the URL in case it's wrong
|
|
git remote set-url origin $GITEA_URL
|
|
else
|
|
git remote add origin $GITEA_URL
|
|
echo "Remote 'origin' added."
|
|
fi
|
|
|
|
|
|
echo "Step 5: Pushing your code to Gitea..."
|
|
git push -u origin main
|
|
|
|
echo ""
|
|
echo "✅ All done! Your code has been pushed to your Gitea repository."
|
|
echo "You can view it at: $GITEA_URL"
|