gpt4 book ai didi

git - 我如何 git squash 更早地一起提交?

转载 作者:太空狗 更新时间:2023-10-29 13:54:50 26 4
gpt4 key购买 nike

我的分支上有大约 10 个提交,比方说 ID 1 到 10。我想将提交 4、5 和 6 压在一起,但保持其余部分不变。我找到的每个教程都从当前的 HEAD 开始,然后用 git rebase -i HEAD~(x amount) 倒退。但是我如何在较早的提交时启动 rebase 并指定一个范围,例如 git rebase -i 6...4 ?

谢谢

最佳答案

只需进行交互式 rebase ,压缩或修复您想要压缩或修复的提交。

git rebase -i HEAD~10

pick a4461d3 
pick d998164
pick 0a1f6e1
f 310ba9d
f 60b7e01
f 7baef60
pick bb9a551
pick badbad1
pick fd9a10c
pick 59ed66f

# Rebase e7e1369..60b7e01 onto fd9a10c (10 command(s))
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out

关于git - 我如何 git squash 更早地一起提交?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42352065/

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