在git push后在两个不同的分支(development和feature)中撤销git提交消息



不希望破坏主分支中的任何内容。

  1. 我通过下面的命令创建了一个开发分支Git签出开发Git pull upstream development #在本地基于使用

    同步本地开发分支
  2. 意外地在该开发分支中进行了少量提交,然后以以下提交返回d3b229f9(开发)合并github.com的分支"开发":ROCmSoftwarePlatform/bench到开发16daa203恢复"内核转换器"工具从库创建yaml文件97e834cb内核转换工具从lib">

    创建yaml文件

  3. git checkout -b kernel
  4. 做了我所有的更改"kernel"分支,推,创建PR,现在需要完成PR.即合并所有内核分支更改开发,但我不想看到d3b229f9,16daa203,97e834cb提交消息,只希望从下面的列表中看到5a555e7a。我怎样才能摆脱3个提交消息从"开发";分支和"内核"部门无缝地?

注意:我做的南瓜合并为内核分支但我不能摆脱提交我在开发分支

"kernel"分支有以下提交,我只想要合并后的5a555e7a消息

5a555e7a (HEAD ->内核,起源/内核)新工具yaml文件

d3b229f9 (develop)合并github.com:softwarePlatform/Benchmark分支'develop'到develop

16daa203恢复内核转换工具从lib logic"创建yaml文件

97e834cb内核转换工具从库逻辑创建yaml文件

f4af1648 (upstream/develop)合并来自xxxxx/develop的pull request #1244

b1a07da2更新版本

您不应该在开发时恢复提交,而应该执行

git reset origin --hard

修复这一切。

# update status
git fetch
# reset develop branch to match origin
git checkout develop
git reset origin --hard
# clean kernel history
git checkout kernel
git log
commit 0080 (HEAD -> kernel, origin/kernel)
Work 2
commit 0070
Work 1
commit 0060
Revert bad stuff
commit 0050
Bad stuff
commit 0040 (develop, origin/develop)
Good work before all this mess
# commit 0040 may not be (develop, origin/develop) if work have
# been done on this branch by someone else. It's not important but
# it makes it harder to find the last good commit.
# at this point keep a copy of the first and last sha of your work
# here 0070..0080
# then reset kernel to the last good commit
git reset --hard 0040
# apply your work
git cherry-pick 0070..0080
# update the PR
git push --force

最新更新