上传GitHub步骤(自用版)

步骤

1、在所需上传至GitHub的文件夹里打开Git Bash,输入git init,将文件夹初始化为仓库;

2、在该文件夹里"右键-用VSCode打开",在VSCode里"查看-终端-切成Git Bash",后续在这里输入命令;

3、目前文件都是在【工作区】,通过 git add -A 将所有文件从【工作区】移到【暂存区】,即从"更改"->"暂存的更改";

4、输入 git commit -m "提交信息" ,从【暂存区】移到【仓库】;

5、在GitHub中新建一个仓库,并复制其网页地址https://github.com/xxx;

6、依次输入命令 git remote add origin https://github.com/xxx.git、git branch -M main、git push -u origin main。

常见报错解决

如果第6步报认证的错(fatal: Authentication failed...),输入命令 git config --global user.email xxx@qq.com

如果报连接的错(Failed to connect to github.com port 443 after 32192 ms: Could not connect to server)

  • 首先,打开设置 -> 网络和Internet -> 代理,找到代理设置,并记录当前代理端口,假设端口号为1234
  • 输入命令 git config --global http.proxy http://127.0.0.1:1234 和 git config --global https.proxy http://127.0.0.1:1234(这里要跟端口号对应上)
  • 然后再 git push origin main 即可

如果报错error: failed to push some refs to,输入命令 git pull --rebase origin main 和 git push origin main 即可。

相关推荐
m0_694845576 小时前
tinylisp 是什么?超轻量 Lisp 解释器编译与运行教程
服务器·开发语言·云计算·github·lisp
June`6 小时前
muduo项目排查错误+测试
linux·c++·github·muduo网络库
weixin_6689 小时前
GitHub 2026年AI项目详细数据汇总表-AI分析-分享
人工智能·github
CoderJia程序员甲1 天前
GitHub 热榜项目 - 日榜(2026-02-05)
ai·开源·大模型·github·ai教程
weixin_6681 天前
GitHub 2026年AI项目热度分析报告-AI分析-分享
人工智能·github
MicrosoftReactor1 天前
技术速递|GitHub Copilot CLI 斜杠命令速查表
github·copilot·cli
wu~9701 天前
GitHub永不遗忘,使用git push -f来覆盖的提交依旧保留
git·github
m0_694845571 天前
music-website 是什么?前后端分离音乐网站部署实战
linux·运维·服务器·云计算·github
独自破碎E1 天前
已经 Push 到远程的提交,如何修改 Commit 信息?
开发语言·github
jiang_changsheng1 天前
工作流agent汇总分析 2
java·人工智能·git·python·机器学习·github·语音识别