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

当我使用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.

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


当前回答

在push之前,你必须添加并提交更改,或者执行git push -f origin master。

其他回答

试试这个Git命令,

git push origin master –f
git push origin master --force

对我来说,我忘记在点击推送之前添加和提交。

So:

git add --all
git commit -m "First commit."

然后按一下,就可以了:)

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

在我的例子中,分支名称前缀已经存在于远程,所以基本上,如果你有一个分支名称“fix”,你不能推送另一个名称为“fix/new_branch_name”的分支。

重命名分支解决了我的问题。

它为我提供了以下几个命令行的组合:

git reset 
git remote -v
git pull --rebase
git init
git add -A
git commit -m "Add your commit"
git branch -M main
git push origin main --force

小心些而已。如果他们有一个自述文件,git重置删除他们。