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

时间:2015-09-30 08:28:20

标签: git merge git-commit

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

  

如果您正在修改已经推送的情况,则应该是这种情况   提交

但我所做的是以下步骤:

  1. 推了一堆代码
  2. commit --amend
  3. commit --amend
  4. commit --amend
  5. 拉(CONFLICT(内容))
  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.
    

1 个答案:

答案 0 :(得分:1)

在步骤2,3,4中,您正在修改已在1

中推送的提交

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

另外,在第5步中,您应该收到警告,或者您最有可能进行强制推送

相关问题