本次目标:将如下weather项目里的所有文件和文件夹通过git上传至GitHub仓库。
1、在GitHub创建好仓库 。
2、 在weather文件夹内右击git bash here打开git。
3、开始进行git操作
git init 进行初始化
git add . 将所有文件包括文件夹都放置暂存区
git commit -m "xxxx" 正式将暂存区的所有文件提交。
git remote add origin (GitHub仓库地址) 绑定本地文件和远程仓库。
git pull --rebase origin main 拉取仓库main分支中的文件。
git branch -m master main 将本地文件的master分支名改成main。
git push -u origin main 将提交好的文件上传到远程仓库。
刷新GitHub后发现本地文件都上传到了仓库中,存在于main分支下。
学习以上内容时所遇到的问题:
问题1:将文件放置暂存区时出现warning: in the working copy of 'icon/font_3626932_fzxieveyp09/demo.css', LF will be replaced by CRLF the next time Git touches it,在第二次输入git add . 成功了。
详细问题及解决:https://blog.youkuaiyun.com/u012757419/article/details/105614028/
问题2:git pull --rebase origin master命令目的在于:在GitHub创建仓库时选择了README文件初始化,需要将仓库中的主分支为main下的文件与本地文件进行合并后才能将本地文件正确的上传至仓库中。
问题3:src refspec main does not match any,在将本地文件传入仓库时,出现main没有匹配到任何。原因在于本地文件默认主分支名为master,无法与仓库的主分支main进行匹配。
此时需要将本地文件的主分支名改为main。尾部蓝色括号内的master表示当前位置为master(主分支)
详细问题解决:error: src refspec main does not match any_TripleGold.的博客-优快云博客_本地仓库没有master
问题4:在最后push到远程仓库时出现
输入命令 :git push -u origin main -f 进行强制上传。
原因:。。。。
文章学习来源:关于git的问题:error: src refspec main does not match any_TripleGold.的博客-优快云博客_本地仓库没有master
Windows下如何将一个文件夹通过Git上传到GitHub上?_geerniya的博客-优快云博客
git提示“warning: LF will be replaced by CRLF”的解决办法_青崖林夕的博客-优快云博客删除github上的一个仓库或者仓库里面的某个文件_加蓓努力我先飞的博客-优快云博客_github删除仓库文件解决:git push时出现 hint: Updates were rejected because the tip of your current branch is behind_wshanshi的博客-优快云博客