Windows将代码上传到github
Windows将代码上传到github
今天是我第一次在Windows上将代码上传到github,在参考了CSDN上的几篇文章之后,终于成功了,大佬们都讲的很细致,而且跟Ubuntu上基本一样,但是我还是要记录一下。
1.安装git
2.第一次要配置SSH,见本文“可能遇到的错误2”
3.github上创建仓库
4.上传过程
进入要上传代码的文件夹,右键,选择“Git Bash Here”
// 1. 初始化
$ git init
// 2. 将整个文件夹变成仓库
$ git add ./
// 3. 添加提交说明
$ git commit -m "Coupling of Iga and Pd in shell structure."
// 4.
$ git remote add origin git@github.com:Hongshuai-Wang/PD-IGA-Shell-Particle.git(去github创建好的仓库复制SSH)
// 5. 上传
$ git push -u origin master
效果:
参考
1.Windows上传代码到Github
2.git学习及问题解决记录
3.Windows下如何将一个文件夹通过Git上传到GitHub上?
github官方指导
5. 更新github上的代码
本地代码更新之后,我们希望github上的代码也更新一下,怎么办呢
// 查看git分支
$ git branch
// 添加更改后的文件
$ git add ./*(根据自身实际更改)
// 添加描述
$ git commit -m "update something"
// 推送到git
$ git push
可能遇到的错误
1. "git add ./"时 warning: LF will be replaced by CRLF…
解决方案
#提交时转换为LF,检出时转换为CRLF
$ git config --global core.autocrlf true
原因:参考
1.IDEA中Git错误LF would be replaced by CRLF in .解决
2.关于 LF will be replaced by CRLF 问题出现的原因以及解决方式
2. git push时 fatal: Could not read from remote repository
原因:SSH没配置好
解决方案
// 1.
$ ls -al ~/.ssh
// 2.生成SSH
$ ssh-keygen -t rsa -C "iwhs321@gmail.com(据说是用户名)"
// 3.复制SSH内容
$ cat ~/.ssh/id_rsa.pub
// 4. 添加到github->Setting->SSH and GOG keys
// 5. 再次验证链接
$ ssh -T git@github.com
效果:
参考:
1.Cloning into ‘order’… The authenticity of host ‘github.com (13.250.177.223)’ can’t be established.
3. fatal: the remote end hung up unexpectedly
原因:文件过大
解决方案
$ git config --global http.postBuffer 524288000
参考
用Git将本地项目上传到GitHub(踩的坑及解决方法)
4. error: Error building trees
解决办法:
$ git reset --hard
参考
git提交时报错error: Error building trees
5. error: remote origin already exists.
解决方案
“origin”重名,换个名字就行
其他方案
Git 提示fatal: remote origin already exists 错误解决办法