收到错误“更新被拒绝,因为您当前分支的提示落后”

gee*_*eks 5 git github bitbucket

我的本地系统代码与 Bitbucket 的远程系统同步,但是出现了一些问题,所以我通过运行git reset --hard HEAD^. 在那之后,我做了一些更改并提交了这些更改。现在,当我尝试在遥控器上推送这些更改时,我收到以下消息:

[vagrant@localhost horizon]$ git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

Password for 'https://user_name@bitbucket.org': 
To https://user_name@bitbucket.org/user_name/repo_name.git
 ! [rejected]        stable/kilo -> stable/kilo (non-fast-forward)
error: failed to push some refs to 'https://user_name@bitbucket.org/user_name/repo_name.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.   
Run Code Online (Sandbox Code Playgroud)

我的问题是,我该如何推动这种情况?请解释。

Von*_*onC 3

a 的问题push --force是,您将强制所有其他贡献者将自己的本地存储库重置为新的 origin/master。

更好的替代方法是使用git revert @(在克隆之后和任何新提交之前完成),以便创建取消当前 HEAD 的新提交。然后您就可以毫无问题地推送它。