创建仓库与认证准备
先搞定 SSH 密钥——进 C 盘用户目录的 .ssh 看看有没有 id_rsa 和 id_rsa.pub,没有的话执行:
ssh-keygen -t rsa -C "[email protected]"
一路回车,然后把公钥内容贴到 GitHub 账号的 SSH Keys 设置里。

如果惯用 HTTPS 操作,还得准备一个 Personal Access Token(建议用 classic,简单够用)。去 Settings → Developer settings → Personal access tokens → Generate new token (classic),勾上需要的权限生成。

仓库直接在 GitHub 主页创建,点一下就行。

本地 Git 设置
先配好身份,全局用户名和邮箱:
git config --global user.name "你的用户名"
git config --global user.email "你的邮箱"
git config --list
代理这一步挺关键——如果你开着代理工具,比如 Clash,通常 HTTP 端口是 7890,设置一下:
git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy http://127.0.0.1:7890
不用代理就清除掉:
git config --global --unset http.proxy
git config --global --unset https.proxy
另外,有时前面设过 GitHub 专用的代理(http.https://github.com.proxy),也可以顺手清掉:
git config --global http.https://github.com.proxy ""
初始化、提交、推送
进项目目录 git init,然后 git add . 把所有文件加入暂存区。Windows 下会看到 的提示,正常的,可以设一下 消除:


