我想用提交消息“第一”和“第二”来压缩两个最新的提交。首先我拉主人然后我使用命令
git rebase -i HEAD~2 master
它在这样的编辑器中向我展示了两个提交:
pick first
pick second
然后我将此编辑器更改为:
pick first
squash second
保存更改后,我收到此消息:
Successfully rebased and updated refs/heads/master.
它确实改变了远程主机中的任何内容。要应用这些更改,我使用git push
命令并收到以下错误:
To https://github.com/aneelatest/GITtest.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/test/GITtest.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.
然后我再次运行该git pull
命令,它合并原始主机并使用此提交消息进行另一次提交:
Merge branch 'master' of https://github.com/aneelatest/GITtest
在此之后,当我运行 git push 时,它会将两个提交压缩为一个并带有消息“first”。问题是在远程主机中,我现在有四个提交:
first
second
Merge branch 'master' of https://github.com/test/GITtest
first
我只想要一个提交,即带有提交消息“first”的压扁的提交。有什么想法我做错了吗?