在GIT推送后,在两个不同的分支(开发和功能)中撤消GIT提交消息

发布于 2025-02-13 00:49:15 字数 884 浏览 0 评论 0原文

不想打破主分支中的任何东西。

  1. i通过下面的命令分配了一个开发分支 GIT结帐开发 git引体向上开发#根据 git push ordent#与

    同步您的本地开发分支
  2. 同步您的本地开发分支,

    意外地在该开发的分支中进行了几乎没有提交,然后恢复了下面的提交 d3b229f9(开发)github.com的合并分支“开发”:rocmsoftwareplatform/bench 16DAA203还原“内核转换器工具,可从lib创建yaml文件 97E834CB内核转换器工具从lib创建yaml文件

  3. 从开发中创建的工作分支,
    git结帐-b内核

  4. 在“内核”分支中进行了所有更改,推动,创建PR,现在需要完成PR。即合并所有内核分支更改要开发,但我不想看到D3B229F9,16DAA203,97E834CB提交消息,只想从下面的列表中看到5A5555E7A。我如何从“开发”分支和“内核”分支中摆脱3个提交消息?

注意:我确实为内核分支合并了,但我无法摆脱我在开发分支

“内核”分支中所做的提交的提交,我只想要5A5555E7A的消息,在合并

5a555e7a 之后)新工具yaml文件

d3b229f9(开发)合并分支“开发” github.com:softwareplatform/benchmark中的开发

16DAA203还原“内核转换器工具,可以从lib逻辑中创建yaml文件”

97e834cb内核转换器工具,以从lib logic

F4AF1648(上游/开发)合并拉力请求#1244 xxxxx/开发

新版本的B1A07DA2更新版本

do not want to break anything in the master branch.

  1. I forked a develop branch through below commands
    git checkout develop
    git pull upstream develop # pull the updates locally based on the
    git push origin develop # sync your local develop branch with

  2. accidentally made few commits in that develop branch then reverted back with below commits
    d3b229f9 (develop) Merge branch 'develop' of github.com:ROCmSoftwarePlatform/bench into develop
    16daa203 Revert "kernel converter tool to create yaml file from lib
    97e834cb kernel converter tool to create yaml file from lib"

  3. Created below work branch from develop,
    git checkout -b kernel

  4. did all my changes in "kernel" branch, pushed,created PR, now need to complete the PR. ie merge all kernel branch changes to develop but I do not want to see d3b229f9,16daa203,97e834cb commit messages, only want to see 5a555e7a from the below list. how can I get rid of 3 commit messages from both "develop" branch and "kernel" branch seamlessly?

Note: I did squash merge for kernel branch yet I could not get rid of commits I made in develop branch

"kernel" Branch has the below commits, I only want 5a555e7a message after the merge

5a555e7a (HEAD -> kernel, origin/kernel) new tool yaml file

d3b229f9 (develop) Merge branch 'develop' of github.com:softwarePlatform/Benchmark into develop

16daa203 Revert "kernel converter tool to create yaml file from lib logic"

97e834cb kernel converter tool to create yaml file from lib logic

f4af1648 (upstream/develop) Merge pull request #1244 from xxxxx/develop

b1a07da2 update version for new release

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

混吃等死 2025-02-20 00:49:16

您不应该恢复发展的承诺,而应该执行

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

You should not have reverted your commit on develop but just perform

git reset origin --hard

To fix all of this.

# 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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文