GitHub - 错误:未能将某些引用推送到'git@github.com:myrepo.git'

Tam*_*mpa 32 github

我收到以下错误.我如何解决?:git add.git commit -m't'git push origin development

To git@github.com:myrepo.git
 ! [rejected]        development -> development (non-fast-forward)
error: failed to push some refs to 'git@github.com:myrepo.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.
Run Code Online (Sandbox Code Playgroud)

Dan*_*ter 70

您的原始存储库位于本地存储库之前.在推送之前,您需要从原始存储库中下拉更改,如下所示.这可以在您的提交和推送之间执行.

git pull origin development
Run Code Online (Sandbox Code Playgroud)

development指的是你要从中拉出的分支.如果你想从master分支拉出然后输入这个.

git pull origin master
Run Code Online (Sandbox Code Playgroud)

  • 上面消息中的`development`指的是你要从中拉出的分支.因此,如果您使用`master`分支,则输入:`git pull origin master` (8认同)

小智 8

就我而言,Github 宕机了。

也许还检查https://www.githubstatus.com/

您可以订阅每封电子邮件和文本的通知,以了解何时可以再次推送您的更改。


Ama*_*ino 7

我使用了这个命令,它对我来说很好用:

>git push -f origin master
Run Code Online (Sandbox Code Playgroud)

但请注意,这可能会删除您在远程仓库中已有的一些文件。由于场景不同,这对我很有用。我正在将我的本地项目推送到远程仓库,该仓库是空的,但 READ.ME


Fid*_*eak 7

我也收到错误 ! [remote rejected] main -> main (failure) error: failed to push some refs to '<repository>'

查了一下才知道原因是这样的:

在此输入图像描述


小智 6

我遇到了同样的问题并解决如下(如果您在本地文件夹中有一个项目,请按照步骤操作):

  1. 在guthub中创建一个新的repo
  2. 转到本地文件夹并执行“git init”
  3. git remote add origin (with your repo url) // 简单地从你的 repo 复制
  4. git add -A
  5. git commit -m "你的提交"
  6. git push -u origin master


小智 6

就我而言。我遇到错误是因为我在 github 上创建存储库到现有项目后忘记进行提交。所以我解决了:

git add .
git commit -m"commentary"
Run Code Online (Sandbox Code Playgroud)

然后我就可以输入:

git push -u origin master
Run Code Online (Sandbox Code Playgroud)


小智 5

你可以在你的控制台写:

git pull origin
Run Code Online (Sandbox Code Playgroud)

然后按TAB键并编写"主"存储库