-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload-to-github.sh
More file actions
112 lines (95 loc) · 2.96 KB
/
Copy pathupload-to-github.sh
File metadata and controls
112 lines (95 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
echo "=================================================="
echo "GitHub Upload Script for Email Scraper"
echo "=================================================="
# Check if Git is installed
if ! command -v git &> /dev/null; then
echo "Error: Git is not installed or not in PATH"
echo "Please install Git and try again"
exit 1
fi
# Check current directory
echo "Current directory: $(pwd)"
echo ""
# Check if this is a Git repository
if ! git status &> /dev/null; then
echo "Error: This is not a Git repository"
echo "Please initialize Git repository first"
exit 1
fi
echo "IMPORTANT: Removing large files that exceed GitHub limits..."
echo ""
# Remove large files from Git history
echo "Removing large Gradle distribution files..."
git rm -r --cached gradle-8.11.1/ 2>/dev/null
git rm --cached gradle-8.11.1-bin.zip 2>/dev/null
echo "Done."
echo ""
# Get repository name from user
read -p "Enter your GitHub repository name (e.g., Email-scraper): " repo_name
if [ -z "$repo_name" ]; then
echo "Error: Repository name cannot be empty"
exit 1
fi
# Get GitHub username from user
read -p "Enter your GitHub username: " github_username
if [ -z "$github_username" ]; then
echo "Error: GitHub username cannot be empty"
exit 1
fi
echo ""
echo "Repository: $repo_name"
echo "GitHub Username: $github_username"
echo ""
# Add all changes (including deletions)
echo "Adding changes to Git..."
git add .
if [ $? -ne 0 ]; then
echo "Error: Failed to add files to Git"
exit 1
fi
# Commit changes
echo "Committing changes..."
git commit -m "Remove large files and prepare for GitHub upload"
if [ $? -ne 0 ]; then
echo "Warning: Failed to commit changes (may already be up to date)"
echo ""
fi
# Add GitHub remote
echo "Adding GitHub remote..."
git remote add origin https://github.com/$github_username/$repo_name.git 2>/dev/null
if [ $? -ne 0 ]; then
echo "Warning: Failed to add remote. It might already exist."
echo "Continuing with existing remote configuration..."
echo ""
fi
# Set main branch (if not already set)
echo "Setting main branch..."
git branch -M main 2>/dev/null
# Push to GitHub
echo "Pushing to GitHub..."
echo "This may take a few minutes depending on your connection speed"
echo ""
git push -u origin main
if [ $? -ne 0 ]; then
echo "Error: Failed to push to GitHub"
echo "Please check your internet connection and GitHub credentials"
exit 1
fi
# Push tags
echo "Pushing tags..."
git push origin --tags
if [ $? -ne 0 ]; then
echo "Warning: Failed to push tags (this is not critical)"
fi
echo ""
echo "=================================================="
echo "SUCCESS! Repository uploaded to GitHub"
echo "=================================================="
echo "Repository URL: https://github.com/$github_username/$repo_name"
echo ""
echo "You can now:"
echo "1. View your repository at the URL above"
echo "2. Continue working on your project"
echo "3. Make changes and use 'git push' to update GitHub"
echo ""