在特定提交之前将git commit移动到

时间:2018-10-24 11:11:19

标签: git

我对GIT进行了一些更改,即a18522,然后将其合并并合并了master,这导致了许多更改。随后,我修复了另一个问题,该问题实际上是合并之前的。

我还没有推送,所以我的更改尚未合并到其他分支。
是否可以在推送之前将我的修复程序下移?

我已经尽了一切,但没有努力。它位于一个名为 ZA

的未推送分支中
166ff44b CM 9 seconds ago   000:Test(s) after merge                    <-- MOVE THIS COMMIT
18b60812 CM 3 hours ago     Merge branch 'master' into za
efef7a58 MK 20 hours ago    without site and without post steps
fc0540a0 MK 20 hours ago    Moved Jenkins Files to root directory
888b8d5d MK 21 hours ago    Jenkinsfile online editiert mit Bitbucket
1d55252d MK 21 hours ago    Jenkinsfile online editiert mit Bitbucket
ba8fc771 MK 21 hours ago    Jenkinsfile online editiert mit Bitbucket
9e8c2e89 MK 21 hours ago    Jenkinsfile online editiert mit Bitbucket
c6cd623d MK 22 hours ago    Jenkinsfile online editiert mit Bitbucket
c3c5310e MK 22 hours ago    pom.xml online editiert mit Bitbucket
a18b79f2 CM 5 days ago      000:New
52212dbc CM 5 days ago      000:Work list speed improvements

因此结果如下:

18b60812 CM 3 hours ago     Merge branch 'master' into za
efef7a58 MK 20 hours ago    without site and without post steps
fc0540a0 MK 20 hours ago    Moved Jenkins Files to root directory
888b8d5d MK 21 hours ago    Jenkinsfile online editiert mit Bitbucket
1d55252d MK 21 hours ago    Jenkinsfile online editiert mit Bitbucket
ba8fc771 MK 21 hours ago    Jenkinsfile online editiert mit Bitbucket
9e8c2e89 MK 21 hours ago    Jenkinsfile online editiert mit Bitbucket
c6cd623d MK 22 hours ago    Jenkinsfile online editiert mit Bitbucket
c3c5310e MK 22 hours ago    pom.xml online editiert mit Bitbucket 
166ff44b CM 9 seconds ago   000:Test(s) after merge                    <-- TO HERE 
a18b79f2 CM 5 days ago      000:New
52212dbc CM 5 days ago      000:Work list speed improvements

1 个答案:

答案 0 :(得分:1)

您可以在互动模式下使用rebase对提交进行重新排序。

这是通过输入以下命令完成的:

git rebase -i a18b79f2

将打开默认的文本编辑器,并按其当前顺序显示提交列表。

只需将提交行剪切/粘贴到您想要的位置,然后保存。

那么你就好了。

有关更多信息,请查看git manual或本参考文章How to undo (almost) anything with Git 中的基准。

P.S。交互式基础库还可用于合并提交,删除提交,更新提交消息...

相关问题