本地项目上传到 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
相关推荐
MicrosoftReactor6 小时前
技术速递|使用 GitHub Copilot SDK 将智能体集成到任何应用中
ai·github·copilot
极智-99618 小时前
GitHub 热榜项目-日榜精选(2026-02-02)| AI智能体、终端工具、视频生成等 | openclaw、99、Maestro等
人工智能·github·视频生成·终端工具·ai智能体·电子书管理·rust工具
樱花落海洋1111 天前
GitHub DeskTop Can`t find URP项目
github
我的golang之路果然有问题1 天前
使用 Hugo + GitHub Pages + PaperMod 主题 + Obsidian 搭建开发博客
golang·go·github·博客·个人开发·个人博客·hugo
codezzzsleep1 天前
fuClaudeBackend:面向fuclaude的轻量后端代理 + Key 管理后台
ai·github·ai编程
kjzd1231 天前
GitHub 热门项目趋势分析报告 (2026年2月2日)
github
LostSpeed1 天前
git - github工程中不能包含大文件
git·github
CoderJia程序员甲1 天前
GitHub 热榜项目 - 日榜(2026-02-02)
人工智能·ai·大模型·github·ai教程
_oP_i1 天前
git gui设置github sshkey
git·github
mathematican1 天前
Git本地修改导致pull失败的解决方法
github