旧提交的git推送编辑

旧提交的git推送编辑,git,push,Git,Push,假设我有提交1-提交2-提交3-提交4。 当我工作的时候,我注意到我在提交3和提交4时遇到了问题,我不想删除它们-所以我回到提交2,做了一些工作并提交了消息last_commit-问题是当我推它时,我得到了这个消息 error: failed to push some refs to 'git@gitlab.com:mo****/*******' hint: Updates were rejected because the tip of your current branch is behin

假设我有提交1-提交2-提交3-提交4。
当我工作的时候,我注意到我在提交3和提交4时遇到了问题,我不想删除它们-所以我回到提交2,做了一些工作并提交了消息last_commit-问题是当我推它时,我得到了这个消息

error: failed to push some refs to 'git@gitlab.com:mo****/*******'
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.  

你说你不想删除commit 3和commit 4,但你还是这么做了。那么,您真正想要实现的是什么呢?提交是不可变的。虽然提交可以是不可变的,但如果提交被推送,则会产生一些影响(提交文档对此有更多的内容要读)。使用git无法实现这一点。最后一次提交是下一次提交的父级。如果不重写历史记录,则不能在两者之间插入提交。如果您认为commit 3中有问题。在提交5中修复它。