-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub_setup.sh
More file actions
88 lines (72 loc) · 2.32 KB
/
Copy pathgithub_setup.sh
File metadata and controls
88 lines (72 loc) · 2.32 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
#!/bin/bash
# GitHub仓库设置脚本
# 请在Git Bash或Linux/Mac终端中运行
echo "=== InsightSphere GitHub 仓库设置 ==="
echo
# 检查Git是否已安装
if ! command -v git &> /dev/null; then
echo "❌ Git未安装,请先安装Git"
exit 1
fi
# 检查是否在Git仓库中
if [ ! -d ".git" ]; then
echo "❌ 当前目录不是Git仓库"
exit 1
fi
echo "✅ Git仓库已初始化"
# 获取用户信息
echo "请输入GitHub用户名:"
read github_username
echo "请输入仓库名称 (默认: InsightSphere):"
read repo_name
if [ -z "$repo_name" ]; then
repo_name="InsightSphere"
fi
echo "请输入仓库描述:"
read repo_description
if [ -z "$repo_description" ]; then
repo_description="实时加密货币数据可视化仪表盘"
fi
echo "是否创建为公开仓库? (y/n, 默认: y):"
read is_public
if [ "$is_public" = "n" ] || [ "$is_public" = "N" ]; then
public_flag="--private"
else
public_flag="--public"
fi
# 检查是否安装了GitHub CLI
if command -v gh &> /dev/null; then
echo "✅ 使用GitHub CLI创建仓库..."
# 创建仓库
gh repo create "$repo_name" $public_flag --description "$repo_description" --confirm
if [ $? -eq 0 ]; then
echo "✅ GitHub仓库创建成功"
# 添加远程仓库
git remote add origin "https://github.com/$github_username/$repo_name.git"
# 推送代码
echo "正在推送代码到GitHub..."
git push -u origin master
if [ $? -eq 0 ]; then
echo "✅ 代码推送成功!"
echo "🎉 仓库地址: https://github.com/$github_username/$repo_name"
else
echo "❌ 代码推送失败,请检查网络连接和权限"
fi
else
echo "❌ GitHub仓库创建失败"
fi
else
echo "⚠️ 未检测到GitHub CLI,请手动创建仓库:"
echo "1. 访问 https://github.com/new"
echo "2. 仓库名称: $repo_name"
echo "3. 描述: $repo_description"
echo "4. 选择公开或私有"
echo "5. 不要初始化README (因为本地已有)"
echo
echo "创建完成后,执行以下命令:"
echo "git remote add origin https://github.com/$github_username/$repo_name.git"
echo "git push -u origin master"
fi
echo
echo "=== 设置完成 ==="
echo "项目已准备好上传到GitHub!"