本地项目上传到 GitHub流程

🔧 第一步:在本地创建 Git 仓库

  1. 新建一个文件夹(如:TEST

    • 可用图形界面新建,也可以使用命令:

      复制代码
      mkdir TEST
      cd TEST
  2. 初始化 Git 仓库:

    复制代码
    git init

📂 第二步:将项目复制进该文件夹并添加到版本库

  1. 将你的项目文件复制粘贴到 TEST 文件夹中。

  2. 查看当前 Git 状态:

    复制代码
    git status
  3. 将所有文件添加到 Git 暂存区:

    复制代码
    git add .
  4. 提交这些文件到本地版本库:

    复制代码
    git commit -m "Initial commit"

🔐 第三步:配置 GitHub SSH Key(只需配置一次

  1. 检查是否已有 SSH key:

    • 查看是否存在文件:C:\Users\你的用户名\.ssh\id_rsa.pub
  2. 如果没有则生成一个新的 SSH 密钥:

    复制代码
    ssh-keygen -t rsa -C "your_email@example.com"
    • 一路按回车即可,默认保存在 .ssh 文件夹中
  3. 查看并复制公钥内容:

    复制代码
    cat ~/.ssh/id_rsa.pub
  4. 登录 GitHub,添加公钥:

    • 进入:Settings > SSH and GPG Keys > New SSH Key

    • 粘贴公钥,点击【Add SSH Key】

  5. 验证 SSH 是否成功连接 GitHub:

    复制代码
    ssh -T git@github.com
    • 成功会看到:Hi username! You've successfully authenticated...

☁️ 第四步:在 GitHub 上新建远程仓库

  • 登录 GitHub → 点击右上角 "+" → 选择 "New repository"

  • 命名新仓库(如:TEST

  • 创建完成后,复制仓库的 SSH 地址,例如:

    复制代码
    git@github.com:your-username/TEST.git

🌐 第五步:将本地仓库关联远程仓库并推送

  1. 添加远程仓库地址:

    复制代码
    git remote add origin git@github.com:your-username/TEST.git
  2. 推送代码到远程仓库(首次用 -u):

    复制代码
    git push -u origin master

✅ 总结:最简上传步骤回顾

复制代码
git init
git add .
git commit -m "first commit"
git remote add origin git@github.com:your-username/your-repo.git
git push -u origin master
相关推荐
峰向AI6 小时前
GenOffice:开源 Office 套件,字节级保留、本地转换、BYOK模式
github
其实防守也摸鱼8 小时前
权限提升与横向移动:从内网渗透到域控的完整技术图谱
运维·服务器·数据库·安全·github·copilot·渗透
m4Rk_8 小时前
【论文阅读】Agent 记忆机制(57):MemSearch-o1——从查询词元生长证据,重组 Deep Search 记忆路径
论文阅读·人工智能·学习·开源·github
其实防守也摸鱼8 小时前
免杀与持久化入门:从载荷免杀到隐蔽通道的完整指南
运维·服务器·数据库·安全·github·copilot·渗透
sec_jay9 小时前
一个面向有限本地语料库的、单智能体、工具调用型 Agentic RAG 原型--关于agent的实践调研报告
github
goplaysource11 小时前
IPTV 频道去重:用哈希解决"同一个频道出现十遍"的问题
github
liuyicenysabel12 小时前
从 0 到 1:一套 GitHub + GHCR + k3s 的全自动 CI/CD 流水线(Flask 项目实战)
ci/cd·flask·github
u13013013 小时前
GitHub 热榜项目:日榜(2026-08-31)
github
Justinsky14 小时前
DeepSeek Harness 开源一个月,我把它整个嵌进了 Electron 桌面软件
github
小宋102114 小时前
MCP 是什么:从零编写一个可供 AI 调用的工具服务
人工智能·github