idea报错:error_ failed to push some refs to ‘[email protected]_walln7_helloworld.git‘

问题描述

在idea中往码云推送新项目时报错:

error: failed to push some refs to ‘[email protected]:walln7/helloworld.git’
To gitee.com:walln7/helloworld.git
hint: Updates were rejected because the remote contains work that you do
! refs/heads/master:refs/heads/master [rejected] (fetch first)
hint: not have locally. This is usually caused by another repository pushing
Done
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. 在项目工作目录下打开Git命令行窗口,执行git pull origin master --allow-unrelated-histories,允许从远程拉取代码,并允许有不相关的历史记录。
  2. 往远程推送代码,执行git push origin master

idea方式

  • 拉取代码后出现:

image.png

  • 选择branch

idea报错:error_ failed to push some refs to ‘git@gitee.com_walln7_helloworld.git‘_第1张图片

  • 执行update

你可能感兴趣的:(#,00,Java-debug,git,intellij-idea,gitee)