修改历史信息
$ git log --oneline # 查看日志
bcffbc0 (HEAD -> main) feat : add d.yaml
363dc97 feat : add c.yaml
5c43069 feat : add b.yaml
b3ca13a feat : add a yaml
$ git rebase -i b3ca13a
pick 5c43069 feat : add b.yaml
->
pick 5c43069 feat : add b.yaml
# 修改前面 pick 内容
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup [-C | -c] <commit> = like "squash" but keep only the previous
# commit's log message, unless -C is used, in which case
# keep only this commit's message; -c is same as -C but
# opens the editor
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
# create a merge commit using the original merge commit's
# message (or the oneline, if no original merge commit was
# specified); use -c <commit> to reword the commit message
# u, update-ref <ref> = track a placeholder for the <ref> to be updated
# to this position in the new commits. The <ref> is
# updated at the end of the rebase
$ git log --oneline # 查看日志
bcffbc0 (HEAD -> main) feat : add d.yaml
363dc97 feat : add c.yaml
5c43069 feat : add b.yaml
b3ca13a feat : add a yaml
$ git rebase -i b3ca13a
pick f6c6202 feat : add b yaml
pick 2e49e53 feat : add c yaml
pick 7b8b211 feat : add d yaml
# 改为
pick f6c6202 feat : add b yaml
squash 2e49e53 feat : add c yaml
squash 7b8b211 feat : add d yaml
# wq 保存后会弹出 Vim
# This is a combination of 3 commits.
# This is the 1st commit message:
feat : add a b c yaml
# This is the commit message #2:
#feat : add c yaml
# This is the commit message #3:
#feat : add d yaml
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Tue Aug 13 19:08:47 2024 +0800
#
# interactive rebase in progress; onto 9265f80
# Last commands done (3 commands done):
# squash 2e49e53 feat : add c yaml
# squash 7b8b211 feat : add d yaml
# No commands remaining.
# You are currently rebasing branch 'main' on '9265f80'.
#
# Changes to be committed:
# new file: cat-b.yaml
# new file: cat-c.yaml
# new file: cat-d.yaml
评论