GitEE常见问题

GitEE常见问题

前言:本文转载,非原创,如有冒犯,请私聊

一、GitHub提交的时显示Updates were rejected because the remote contains work that you do

每次建立新的仓库,提交的时总会出现这样的错误。Updates were rejected because the remote contains work that you do

错误的git 提交的步骤:

  1. git init //初始化仓库
  2. git add .(文件name) //添加文件到本地仓库
  3. git commit -m “first
  4. commit” //添加文件描述信息
  5. git remote add origin + 远程仓库地址 //链接远程仓库,创建主分支 git
  6. push -u origin master //把本地仓库的文件推送到远程仓库

这样就显示这样的问题了,如下图。
在这里插入图片描述
经过查资料发现是因为我们在本地新建库后,与远程仓库的内容不一致导致的。为此在我向远程库推送的时候,要先进行pull,让本地新建的库和远程库进行同步。

正确步骤:

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

原文链接:https://blog.csdn.net/aiming66/article/details/81051428

二、Updates were rejected because the tip of your current branch is behind

git提交冲突问题:

Updates were rejected because the tip of your current branch is behind
方案:

这时需要用git pull origin master --allow-unrelated-histories指令

List item

  1. 按”i”进入输入模式在这里插入图片描述

  2. 然后 esc键,直接输入”:wq”你会发现这个出现在终端的最下面在这里插入图片描述

  3. 最后 enter。
    注:如果输入指令成功执行,没有报错,可以不用1 2 3 步,正常步骤提交即可。

三、fatal:‘origin’ does not appear to be a git repository fatal:Could not read from remote repository

今天gitlab中遇到的问题:

当 git push origin branch_name时遇到报错如下:

fatal:‘origin’ does not appear to be a git repository

fatal:Could not read from remote repository

原因:

本地分支和远程分支断开连接

解决方法:

cd 本地分支里
1、git branch
——*master 只显示master

然后查看是否从上游拉了
2、git remote –v
——若什么都没有,则和上游已断联系,拉不了代码也推不了代码

加关联
3、git remote add origin ssh://git@gitlab*********************************.git(地址)

然后
4、git fetch origin

          ——会显示下拉的branch情况

                格式为From ssh://gitlab.********************************

              *  [new branch]         XXXXX        ->origin/XXXXX

再次检查远程仓库,显示对应的clone地址
git remote –v
——origin git://github.com/schacon/ticgit.git (fetch)
origin git://github.com/schacon/ticgit.git (push)

然后再查分支
git branch –a

        ——* mater

               remotes/origin/XXXXXX         **********

具体的切换分支可参考https://blog.csdn.net/tanningzhong/article/details/79724488

git 重命名仓库、修改远程仓库地址、修改仓库配置可参考:https://blog.csdn.net/u011884440/article/details/71246572

原文链接:https://blog.csdn.net/qq_44701258/article/details/99087161

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值