【Github】hint: Updates were rejected because the remote contains work that you do && remote: error: G

Q:git push报错

hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push --help’ for details.

翻译

提示:更新被拒绝,因为远程包含您所做的工作
提示:不要在本地使用。这通常是由另一个存储库推送引起的
提示:对于相同的ref。您可能需要首先集成远程更改
提示:(例如,“git pull…”)然后再次按下
提示:有关详细信息,请参阅“git推送-帮助”中的“关于快进的说明”

A:这是因为在上传的时候,远程仓库中有着本地仓库没有的文件(与远程仓库的内容不一致),即导致本地仓库和远程有不同的开始点,也就是两个仓库没有共同的 commit ,所以无法提交,解决方法如下:

1. git pull origin main --allow-unrelated-histories

2.git pull origin main

3.git init		

4.git remote add origin ssh://git@github.com:Hahalim2022y/slam_test.git

5.git add .		

6.git commit -m "test"

7.git push -u origin main

参考教程https://www.cnblogs.com/yanhuidj/p/9301328.html

正确的提交过程如下:

git init                           //初始化仓库
git add .(文件name)                //添加文件到本地 
git commit -m "first commit"      //添加文件描述信息
git remote add origin  远程仓库地址 //链接远程仓库 
git pull origin master           // 把本地仓库的变化连接到远程仓库master/main分支
git push -u origin master        //把本地仓库的文件推送到远程仓库master/main分支

Q:git push 超过100M资源时,提示remote: error: GH001: Large files detected. GitHub’s file size limit of 100M
A:下载Git-LFS,并安装,cmd进入安装后的目录,执行·git lfs install
在这里插入图片描述
在这里插入图片描述

//选择需要提交到Git-LFS的文件
git lfs track "文件"

//跟踪.gittattributes
git add .gitattributes

//下面操作跟Git操作一样
git add cmder-tool.zip
git commit -m "commit"
git push -u origin master
  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值