当前位置:   article > 正文

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

hint: updates were rejected because the remote contains work that you do hin

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.
  • 1
  • 2
  • 3
  • 4
  • 5

翻译

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

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

参考教程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分支
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/451154
推荐阅读
相关标签
  

闽ICP备14008679号