为什么我在push->amend->amend->amend->push->pull之后会有冲突?

Why should I have conflict after push->amend->amend->amend->push->pull?

在这个问题Git prevents pushing after amending a commit中提到:

This should only be the case if you're amending an already-pushed commit

但我所做的是以下步骤:

  1. 推了一堆代码
  2. 提交 --amend
  3. 提交 --amend
  4. 提交 --amend
  5. 已推送
  6. 拉(冲突(内容))

以后也可能会发生这种冲突,我不明白为什么会发生冲突!有人可以阐明这个过程吗?


在第 4 步中:

$ git commit --amend
[dev cf0f21d] blahhh(blah) is added
 Date: Wed Sep 30 08:39:28 2015 +0330
 5 files changed, 168 insertions(+), 1 deletion(-)

在第 5 步中:

$ git push origin dev
To repo:~/something
 ! [rejected]        dev -> dev (non-fast-forward)
error: failed to push some refs to 'repo:~/something'
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.

在步骤 2、3、4 中,您正在修改已在 1 中推送的提交

Commit amend 修改 repo 中的最后一次提交。因此,您正在修改您已经在 1 中推送的提交。 您需要在 (1) 之后创建一个新的提交,然后您可以根据需要修改该提交。

此外,在第 5 步中您应该收到警告,或者您很可能执行了强制推送