必威体育Betway必威体育官网
当前位置:首页 > IT技术

git 无法push远程仓库 Note about fast-forwards

时间:2019-07-06 12:43:21来源:IT技术作者:seo实验室小编阅读:76次「手机版」
 

forwards

问题

push远程仓库时,经常报出下面的错误,导致操作失败,让我们来看看怎么解决。

To github.com:zwkkkk1/chatroom.git
 ! [rejected]        master -> master (non-fast-forward)
ERROR: failed to push some refs to '[email protected]:zwkkkk1/chatroom.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 again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

错误:non-fast-forward

远程仓库:origin

远程分支:master

本地分支:master

解决方案

Git 已经提示我们,先用 git pull 把最新的内容从远程分支(origin/master)拉下来,然后在本地 merge,解决 conflict,再 push

不过,在 git pull 时,还有其他的错误,我们分别看看可能出现的错误。

fatal: refusing to merge unrelated histories

  此项错误是由于本地仓库和远程有不同的开始点,也就是两个仓库没有共同的 commit 出现的无法提交。这里我们需要用到 --allow-unrelated-histories。也就是我们的 pull 命令改为下面这样的:

git pull origin master --allow-unrelated-histories

如果设置了默认分支,可以这样写

git pull --allow-unrelated-histories

There is no tracking information for the current branch.

完整报错代码可能是这样的:

There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

原因是没有指定本地 master 分支和远程 origin/master 的连接,这里根据提示:

git branch --set-upstream-to=origin/master master

产生冲突

  pull 还可能产生 conflict,这里需要自己手动解决冲突再 merge,这里不过多介绍。

成功 git pull 之后,然后就可以成功 git push 了~~

相关阅读

Windows远程时无法复制文件--杀进程rdpclip.exe,然后再

1.远程登陆到主机上2.任务管理器杀进程rdpclip.exe3.【开始】,搜索rdpclip.exe,点击运行此时重新复制文件,可以跨主机复制啦原以为是

操作系统篇(一):Windows7无法修改主题的根源

今天打开电脑有一阵,正在调试Python程序,突然感觉电脑异常的慢,对于我来说这种速度是相当于的诡异,就像给你一辆飞机,结果你偏偏要用人

没有京东自提点怎么办?京东无法自提怎么办?

没有京东自提点怎么办?自己去京东自提点哪去快递,就可以免运费,但是自提点覆盖面并不是很广,那么没有京东自提点怎么办?京东无法自提

ORA-12154: TNS: 无法解析指定的连接标识符

前几天我在笔记本电脑上用plsql连接oracle数据库时提示ORA-12154: TNS: 无法解析指定的连接标识符,遇到这种问题我就用常规解决方

centOS 7下无法启动网络(service network start)错误解

   今天在centOS 7下更改完静态ip后发现network服务重启不了,翻遍了网络,尝试了各种方法,终于解决了。现把各种解决方法归纳整理,希

分享到:

栏目导航

推荐阅读

热门阅读