记一次Git提交报错的问题

通常代码版本控制的步骤是:

  • 在代码版本控制平台新建一个仓库
  • clone远程仓库到本地
  • 开始编码,然后是一系列add,commit,push

    我的步骤是:

  • 在远程代码版本管理平台新建一个仓库
  • 在本地新建一个项目
  • 通过git remote add添加远程仓库
  • 然后add, commit, push
    但是commit时就报错了:
error: failed to push some refs to ....
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.

这说明此时两个仓库并没有建立关联,两个仓库的代码没有同步。
按照提示使用git pull拉取远程代码并合并又出现如下错误:

 refusing to merge unrelated histories

意思是两个仓库的历史记录不相关。

最终解决方案:

允许不相关的历史:

git pull origin master --allow-unrelated-histories

然后再push.

原文地址:https://www.cnblogs.com/wotoufahaiduo/p/11669074.html

时间: 2024-08-26 05:24:41

记一次Git提交报错的问题的相关文章

git提交报错SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version

git push报错 git push origin master [email protected] /e/git/ouyida3/ouyida3.github.io (master) $ git push origin master fatal: unable to access 'https://github.com/ouyida3/ouyida3.github.io.git/': err or:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tl

git提交报错

Error occurred computing Git commit diffsMissing unknown 0000000000000000000000000000000000000000 commit操作时,出现如上错误

<问题解决02>Linux虚拟机使用git push报错--解决方案如下:

问题描述: 使用git push 报错: error: The requested URL returned error: 403 Forbidden while accessing https://github.com/Newlyfly/Hello_World.git/info/refs fatal: HTTP request failed 解决方案: 解决方案来源博客地址:http://blog.csdn.net/happyteafriends/article/details/1155404

git push报错error: failed to push some refs to '[email protected]:

$ git push -u origin master To [email protected]:xxx/xxx.git ! [rejected] master -> master (fetch first) error: failed to push some refs to '[email protected]:xxx/xxx.git' hint: Updates were rejected because the remote contains work that you do hint:

git checkout 报错 refname 'origin/branch-name' is ambiguous

When this happened, it created the file .git/refs/heads/origin/branch-name. So, I just deleted the file. 执行 rm .git/refs/heads/origin/分支名 再checkout git checkout 报错 refname 'origin/branch-name' is ambiguous 原文地址:https://www.cnblogs.com/cheng6018/p/847

git push 报错:failed to push some refs to '[email protected]:devops/thor.git'

error: failed to push some refs to '[email protected]:devops/thor.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing

git bash提交代码过程 以及 git pull报错 your local changes to the following files would be overwritten by merge:

git bash 平常提交代码流程: 1. 在文件根目录下鼠标右键点击空白处,选择git Base here 2. git status 查看哪些文件被修改,文件状态为 modified, 也就是被修改了,“Changes not stagged for commit”表示文件被修改但是提交前还没有被存储 3. git add 将修改添加到暂存区(git commit之前必须要执行这一步) git add . : 是将所有被修改的文件和新增加的文件,但不包括被删除的文件 添加到缓存区 git a

git cherry-pick 报错 fatal: bad object

场景:程序员A提交了一个commit到gerrit上,我们叫他为commit_id1,但是还没有review,那就是没有入库,程序员B想再本地拿到这个commitd_id1,既然这个提交没有入库,很明显,B单纯执行git pull是拿不到这个提交的,那他要怎么办呢, 目前我想到的有几种方式:第一种如果只是单纯了改了很少量的文件,我们不排斥程序员A把这几个文件直接发给B.如果改动比较大呢?第二种,程序员A本地关于这个提交生成一个patch,发给B,B再在本地把这个patch打上,这是个不错的方式.

使用git提交时报错:error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large

Delta compression using up to 4 threads.Compressing objects: 100% (2364/2364), done.Writing objects: 100% (4329/4329), 1.15 MiB | 11.20 MiB/s, done.Total 4329 (delta 2657), reused 3050 (delta 1497)error: RPC failed; HTTP 413 curl 22 The requested URL