gpt4 book ai didi

github)从 merge 中删除提交

转载 作者:太空狗 更新时间:2023-10-29 14:27:28 30 4
gpt4 key购买 nike

我的问题类似于 git remove commit from a merge但我不能按照那里建议的说明进行操作,因为我的存储库的历史有点不同。

我正在 github 上开发一个开源存储库。几个月后,我想更新我的本地存储库,但我错误地进行了无用的 merge 提交。历史如下所示:

* commit 3d542ddb64e6474a10dfface24defc69b713a295
| Author: TD
|
| fixed typo in dependency_injection/compilation chapter
|
* commit 34db3b8c08e5c5d3be4021076716ed90187fe5fb
|\ Merge: b8b73fb 7cc08f4
| | Author: TD
| |
| | Merge remote-tracking branch 'upstream/master'
| |
| * commit 7cc08f476b7ac5610b1eb5b5db5182d18e35a9e9
| | Author: RW
| |
| | [#1654] Tweaking comments
...

我的小改动应该只有一个提交,但有两个。我只想删除 34db3b8c0... merge 提交。我知道我应该尝试交互式 rebase ,但我不知道如何设置它。当我尝试

git rebase -i HEAD~2

我得到了一个巨大的过去提交列表:

pick bbfbddb Add the new "strict_requirements"
pick 31bb8a9 [reference] Tweaking note about strict_requirements
pick fb4d621 [Cookbook][Extension] Fixed typo in functions name
pick d8d1d86 Fixing index typo
# lots and lots of commits in the history here
pick c734436 Fixed indentation.
pick ca8d884 Update cookbook/logging/channels_handlers.rst
pick 7cc08f4 [#1654] Tweaking comments in channel handlers doc to point to reference
pick 3d542dd fixed typo in dependency_injection/compilation chapter: should be contAiner instead of continer

# Rebase b8b73fb..3d542dd onto b8b73fb
#
# Commands:
...

但是当我尝试时:

git rebase -i HEAD~1

(想要一个更短的列表)我只得到一个提交:

pick 3d542dd fixed typo in dependency_injection/compilation chapter: should be contAiner instead of continer

据我所知,我应该压缩 merge 提交 34db3b8c08... 使用交互式 rebase ,对吧?

感谢您的帮助。

最佳答案

试试 git rebase upstream/master。因此,您的提交将应用于远程主机。 merge 提交将被丢弃。

关于github)从 merge 中删除提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12339568/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com