git --amend --no-edit拒绝推送

Ema*_*rsa -1 git push git-amend

今天我发现--no-edit--amend.但是,它引出了以下问题.这里的步骤:

  • git clone
  • 对代码做了一些更改
  • git add.
  • git commit --amend --no-edit
  • git push origin master

    ! [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.
    
    Run Code Online (Sandbox Code Playgroud)

为什么?

注意:我是唯一一个处理该回购的人.

tal*_*rer 5

修改上次提交会重写历史记录.如果这就是你想要做的事情,你可以做到这一点git push --force.

它告诉你落后的原因是因为本地和远程存在的最后一次提交(又名"合并基础")是提示的父级.在这方面,你是远程的一个提交,它已经在上述合并基础之上提交了一个提交.