本地代码上传到GitHub步骤
1.创建新的仓库
- 在Github网页中创建一个仓库
2.设置git
- 安装git
- 配置用户名和邮箱
git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"
3.初始化本地仓库
- 定位到本地仓库所在位置
cd /E
- 运行以下命令初始化仓库
git init
4.添加和提交本地代码
- 添加文件到git
git add .
- 提交文件
git commit -m "这里写你的备注"
5.关联本地仓库和Github远程仓库
- 在Github仓库页面中复制URL,如
- 关联至远程仓库
git remote add origin 新建仓库的URL
6.将代码推送到GitHub
- 先将远程仓库的文件与本地合并(空仓库可忽略)
git pull --rebase origin main
- 推送
git push -u origin main
至此可在GitHub仓库中看到推送的代码。
7.代理设置(如报错Failed to connect to github.com port 443 )
- 配置socks5代理
git config --global http.proxy socks5 127.0.0.1:15236
git config --global https.proxy socks5 127.0.0.1:15236
- 配置http代理
git config --global http.proxy 127.0.0.1:15236
git config --global https.proxy 127.0.0.1:15236
再重新执行第六步推送命令