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

当我使用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 remote add origin https://github.com/donhuvy/accounting133.git
git remote -v
git add .
git commit -m"upload"
git push --set-upstream origin master

在您的情况下更改远程存储库的URL。你可以跳过命令git remote -v,只是为了检查。

其他回答

如果您正在使用git push origin master,请将其更改为git push origin main,反之亦然。

在推送之前未提交初始更改也会导致问题。

你的宣传和你的故事有关吗。如果是,检查jira的工作流程状况。 管理员可以根据某些工作流程配置为只允许推送。

事实上,GitHub将master改为main让我遇到了这个问题。所以从现在开始,推到原点的解决方案是:

git push -u origin main

我不确定这是否适用,但对我来说,修复是在git初始化后在本地提交一些东西。然后我使用——set-upstream推到远程。