使用git工具上传本地代码到Github
下载地址:Git工具
参考网址1:本文参考来源
- 在github主页创建一个新仓库
- 复制URL地址
- win+D,然后右键打开git bash,完成以下步骤:
- cd 进入本地代码所在地址
- 输入git clone +刚刚复制的URL地址
- 进入到本地代码存放的地址会发现一个新生成的文件夹,这是刚刚在网站上新建的仓库,把本地代码拖到这个新文件夹里。
- 在git bash输入 cd 新文件夹名称
- 依次输入以下代码
git add --all
git commit -m "first commit" #(first commit表示第一次提交,可以根据需要改成自己想要备注的文字,汉字亦可)
git push -u origin master #(第一次提交需要输入-u,往后就不用输入了,这是最后一步,表示把本地代码上传到云端仓库。这一步需要输入用户名和密码进行验证)
补充说明:
问题1:使用git add --all 报错warning: in the working copy of ‘Course 3.ipynb’, LF will be replaced by CRLF the next time Git touches it
解决方法:
git config --global core.autoCRLF
参考网址2: 解决上述报错的参考链接
问题2:使用git push -u origin master,报错error: src refspec master does not match any
解决办法:
git push -u origin main