1,在github上创建仓库
2,复制仓库地址
3,到本地项目所在的根目录,右键git bash here
4,在打开的git 窗口中,粘贴复制的仓库地址
git clone https://github.com/.../xx.git
此时会看到代码根目录里面又多了一个与仓库同名的文件夹,将根目录里所有其他的文件都移到这个新的文件夹里;然后进到此文件夹中
5,将项目所有文件添加到git,然后提交
git add .
git commit -m "first commit"
(出现warning问题不大,不用管就行。此处warning好像是换行符在Windows与Linux系统里指令不一样)
6,推送到远程github仓库
$ git push -u origin main
此时可能会出现弹窗,让输入personal access token,这个在github上手动设置
参见这篇文章设置 GitHub创建Personal access tokens(个人访问命令)_10瓶佳得乐的博客-CSDN博客_github tokens
但建议select scopes 勾选上 ‘workflow’,不然可能会出现以下错误
出现这种错误就update一下token再执行推送命令
7,可能会出现的错误
RPC failed; curl 28 OpenSSL SSL_read: Connection was reset, errno 10054
send-pack: unexpected disconnect while reading sideband packet
解决:SSL证书错误,让git忽略它
git config --global http.sslVerify "false"
还有一种错误
RPC failed; curl 18 transfer closed with outstanding read data remaining
send-pack: unexpected disconnect while reading sideband packet项目可能太大了‘RPC失败;curl 18传输结束,剩余未完成的读取数据’’
解决:加大缓存区(以500M为例:)
git config --global http.postBuffer 524288000