我昨天还能推,现在却推不动了。

当我使用git push origin master时,我得到一个错误:

$ git remote -v
origin  https://github.com/REDACTED.git (fetch)
origin  https://github.com/REDACTED.git (push)

$ git push origin master
Username for 'https://github.com': REDACTED
Password for 'https://REDACTED@github.com':
To https://github.com/REDACTED.git
! [rejected]         master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/REDACTED.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.

我的工作目录和远程存储库看起来像什么:


当前回答

git push -u origin main出错?试试这个解决方案。它将100%工作。

Git push origin master,改为Git push origin main

如何更换Main?

git分支-M main

其他回答

这些步骤对我很有效:

切换到当前分支和拉最新的代码 重命名本地分支 Git分支-m [new-name] 将本地分支推到服务器 Git push origin [new-name] 从服务器中删除分支 Git push origin——delete [old-name]

不幸的是,我无法用其他解决方案解决这个问题,但我的问题是我想要推送的分支名称不被远程接受。我把它改成了正确的格式,它被接受了。

它是test/testing_routes,我需要将其更改为testing_route,其中正斜杠(/)是远程不允许的。

您应该确保分支名称格式正确。

我尝试了'git push origin main',然后收到了消息。然后我尝试单独使用“git push”,但它不起作用。

我检查了一下我是否承诺了(是的)。我试着“拉”,然后“推”,但没有。

在开始一些特技之前,我只是关闭并打开一个新的终端,然后再次“推”,它工作了:p

如果您正在使用Gerrit,这可能是由提交中不适当的Change-id引起的。尝试删除Change-Id,看看会发生什么。

git init Git远程添加origin https://gitlab.com/crew-chief-systems/bot Git remote -v(用于检查当前存储库) 添加所有文件 git commit -m '添加我的项目' Git pull -rebase origin master Git push origin master