参考资料
https://blog.csdn.net/m0_37725003/article/details/80904824
https://blog.csdn.net/liereli/article/details/80824804
https://www.cnblogs.com/wei325/p/5278922.html
https://blog.csdn.net/lindexi_gd/article/details/52554159
https://blog.csdn.net/gongqinglin/article/details/79752398
创建一个新的项目
创建完成之后,下面红框中的网址要记住,在后面上传代码的时候需要使用
安装git
安装包:https://git-scm.com/download/win
安装完成之后,双击打开Git Bash
命令行
cd 文件夹//进入项目目录
git init //初始化仓库
git add .(文件name) //添加文件到本地仓库
git commit -m “first commit” //添加文件描述信息
git remote add origin + 远程仓库地址 //链接远程仓库,创建主分支
git pull origin master --allow-unrelated-histories //把本地仓库的变化连接到远程仓库主分支;
//最新的版本需要添加 --allow-unrelated-histories 告诉git允许不相关历史合并
git push -u origin master //把本地仓库的文件推送到远程仓库
问题及解决办法
1) git add .报错:The file will have its original line endings in your working directory
解决方法:git rm -r --cached .
git config core.autocrlf false
git add .
2) git中Please enter a commit message to explain why this merge is necessary.
Please enter a commit message to explain why this merge is necessary.
git在pull或者合并分支的时候有时会遇到这个界面。可以不管(直接下面3,4步),如果要输入解释的话就需要:
1.按键盘字母 i 进入insert模式
2.修改最上面那行黄色合并信息,可以不修改
3.按键盘左上角"Esc"
4.输入":wq",注意是冒号+wq,按回车键即可
3)error: pathspec 'xxx did not match any file(s) known to git
解决方法:删除缓存的文件(只从路径中删除路径,而不是真正的文件!)git rm -r --cached .
将所有文件添加到索引中git add .
承诺git commit -m “hopefully fixed pathspec error”
相关文章: