-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub-setup.sh
More file actions
121 lines (103 loc) · 4.86 KB
/
Copy pathgithub-setup.sh
File metadata and controls
121 lines (103 loc) · 4.86 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
113
114
115
116
117
118
119
120
121
#!/bin/bash
# GitHub Setup Script for Docker Container
# Run this inside the container: ./github-setup.sh
set -e
echo "╔══════════════════════════════════════════════════════════╗"
echo "║ GitHub Setup Wizard ║"
echo "╚══════════════════════════════════════════════════════════╝"
echo ""
# Step 1: Configure Git identity
echo "📝 Step 1: Configure Git Identity"
echo "─────────────────────────────────"
read -p "Enter your name (for commits): " GIT_NAME
read -p "Enter your email (GitHub email): " GIT_EMAIL
git config --global user.name "$GIT_NAME"
git config --global user.email "$GIT_EMAIL"
echo "✅ Git identity configured!"
echo ""
# Step 2: Choose authentication method
echo "🔐 Step 2: Choose Authentication Method"
echo "────────────────────────────────────────"
echo "1) SSH Key (recommended for frequent use)"
echo "2) Personal Access Token (simpler setup)"
echo ""
read -p "Choose option (1 or 2): " AUTH_METHOD
if [ "$AUTH_METHOD" = "1" ]; then
# SSH Key Setup
echo ""
echo "🔑 Generating SSH Key..."
echo "─────────────────────────"
# Generate SSH key
ssh-keygen -t ed25519 -C "$GIT_EMAIL" -f ~/.ssh/id_ed25519 -N ""
# Start ssh-agent and add key
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
echo ""
echo "╔══════════════════════════════════════════════════════════╗"
echo "║ 📋 COPY THIS SSH PUBLIC KEY TO GITHUB ║"
echo "╚══════════════════════════════════════════════════════════╝"
echo ""
cat ~/.ssh/id_ed25519.pub
echo ""
echo "────────────────────────────────────────────────────────────"
echo ""
echo "👉 Steps to add to GitHub:"
echo " 1. Go to: https://github.com/settings/keys"
echo " 2. Click 'New SSH key'"
echo " 3. Paste the key above"
echo " 4. Click 'Add SSH key'"
echo ""
read -p "Press Enter after adding the key to GitHub..."
# Test SSH connection
echo ""
echo "🧪 Testing GitHub SSH connection..."
ssh -T git@github.com -o StrictHostKeyChecking=no || true
echo ""
echo "✅ SSH setup complete!"
echo ""
echo "📌 Use SSH URLs for your repos:"
echo " git remote add origin git@github.com:USERNAME/REPO.git"
else
# Personal Access Token Setup
echo ""
echo "🎫 Personal Access Token Setup"
echo "───────────────────────────────"
echo ""
echo "👉 Steps to create a token:"
echo " 1. Go to: https://github.com/settings/tokens"
echo " 2. Click 'Generate new token (classic)'"
echo " 3. Give it a name, select 'repo' scope"
echo " 4. Click 'Generate token'"
echo " 5. Copy the token (you won't see it again!)"
echo ""
read -p "Press Enter when you have your token ready..."
# Configure credential helper to store token
git config --global credential.helper store
echo ""
echo "✅ Token auth configured!"
echo ""
echo "📌 Use HTTPS URLs for your repos:"
echo " git remote add origin https://github.com/USERNAME/REPO.git"
echo ""
echo "💡 When you push, enter:"
echo " - Username: your GitHub username"
echo " - Password: paste your token"
echo ""
echo " (Credentials will be saved after first use)"
fi
echo ""
echo "╔══════════════════════════════════════════════════════════╗"
echo "║ ✅ GitHub Setup Complete! ║"
echo "╚══════════════════════════════════════════════════════════╝"
echo ""
echo "📁 Your code is in: /workspace"
echo ""
echo "🚀 Quick commands to push your code:"
echo " cd /workspace"
echo " git init"
echo " git add ."
echo " git commit -m 'Initial commit'"
echo " git branch -M main"
echo " git remote add origin <your-repo-url>"
echo " git push -u origin main"
echo ""