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 错误解决办法

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值