【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
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
"hint: updates were rejected because the remote contains work that you do hin"的意思是"提示:更新被拒绝,因为远程存储库包含您已经有的工作"。 当我们想要将本地的更新推送到远程存储库时,有时会遇到这样的错误提示。这个错误通常发生在我们尝试将本地分支的更改合并到远程分支时。提示意味着在我们推送更新之前,远程分支已经存在了我们本地已经有的一些工作。 出现这个问题的原因可能是由于其他用户或者团队成员在我们尝试推送更新之前,已经先行推送了一些更改到远程分支。这种情况下,我们的本地分支就会落后于远程分支的变更。为了避免冲突,Git会拒绝我们的推送。 解决这个问题的方法通常有以下几种: 1. 拉取最新更改:使用`git pull`命令,从远程仓库拉取最新的更改。这将合并远程分支的更改到我们的本地分支。 2. 解决冲突:如果`git pull`产生了冲突,在Git的冲突标记中手动解决冲突,合并我们的更改与远程更改。 3. 强制推送:如果我们明确知道我们的本地更改是合理的,并且我们不关心丢失远程更改,可以使用`git push -f`命令来强制推送本地更改。但是,这种方法可能会导致远程分支的代码丢失,因此应谨慎使用。 总结起来,出现"hint: updates were rejected because the remote contains work that you do hin"的错误提示,意味着我们的本地分支在推送之前和远程分支发生了冲突。我们可以通过拉取最新更改、解决冲突或强制推送来解决该问题。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值