$ git log --oneline
acb05b3 Some final commit.
4968dbd Fixing an error in commit df89a81.
df89a81 Something committed too early.
c365eab Another commit...
625889f A commit...
70f29fd The beginning.
我想要将代码库rebase到最近提交之前的三个提交:
$ git rebase -i HEAD~3
pick df89a81 Something committed too early.
pick 4968dbd Fixing an error in commit df89a81.
pick acb05b3 Some final commit.
# Rebase c365eab..acb05b3 onto c365eab (3 command(s))
我将其更改为:
pick df89a81 Something committed too early.
squash 4968dbd Fixing an error in commit df89a81.
pick acb05b3 Some final commit.
# Rebase c365eab..acb05b3 onto c365eab (3 command(s))
# This is a combination of 2 commits.
# The first commit's message is:
Something committed too early.
# This is the 2nd commit message:
Fixing an error in commit df89a81.
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
我将其更改为:
# This is a combination of 2 commits.
# The first commit's message is:
This is the squashed commit. It and everything after it get new commit hashes.
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
$ git log --oneline
8792fef Some final commit.
df775c4 This is the squashed commit. It and everything after it get new commit hashes.
c365eab Another commit...
625889f A commit...
70f29fd The beginning.
development
分支有什么不同?git rebase -i development
应该尝试将当前分支中尚未包含在development
分支中的每个提交进行变基。 - David Scarlettgit log
相反的顺序列出。即最旧的在前,最新的在后。 - David Scarlett