git--修改--无编辑拒绝推送

git--修改--无编辑拒绝推送,git,push,git-amend,Git,Push,Git Amend,今天我发现了--amend的--no edit。然而,这让我想到了以下问题。以下是步骤: git克隆 对代码做了一些更改 git添加 git提交--修改--不编辑 git推送源主机 ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://me@bitbucket.org/myRepo.git' hint: Updates were rejecte

今天我发现了
--amend
--no edit
。然而,这让我想到了以下问题。以下是步骤:

  • git克隆
  • 对代码做了一些更改
  • git添加
  • git提交--修改--不编辑
  • git推送源主机

    ! [rejected]        master -> master (non-fast-forward)
    error: failed to push some refs to 'https://me@bitbucket.org/myRepo.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.
    
为什么?


注:我是唯一一个在该回购协议上工作的人。

修改上次提交将重写历史。如果这是您想要做的,您可以使用
gitpush--force
来完成


它告诉您您落后的原因是因为本地和远程都存在的最后一次提交(也称为“合并基”)是tip的父项。在这方面,您是远程服务器后面的一个提交,远程服务器在前面提到的合并基础上已经有了一个提交。

这只是一个愚蠢的问题,您在尝试推之前是否已经拉过(提示提示)?我刚刚签出,当您执行
git fetch origin
时,它不能落后,
origin/master
跟踪分支是否有任何信息?没有,但如果我刚签出,为什么要提取?可能是Good catch+1的重复,我完全错过了这一点。从本质上讲,本地和远程主分支已经分化,因为最常见的提交现在是刚刚重写的提交之前的提交。