Git 重写

作者: DrCoffee84创建于 2025年2月4日更新于 2025年9月1日

$ git rebase -i --root [detached HEAD pick b8c90c6 2. Added Luigi pick 09801b5 1. New file

Rebase 09801b5..b8c90c6 onto 09801b5 (1 command)

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 [-C | -c] = 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 = run command (the rest of the line) using shell

b, break = stop here (continue rebase later with 'git rebase --continue')

d, drop = remove commit

l, label = label current HEAD with a name

t, reset = reset HEAD to a label

m, merge [-C | -c ] [# ]

create a merge commit using the original merge commit's

message (or the oneline, if no original merge commit was

specified); use -c to reword the commit message

u, update-ref = track a placeholder for the to be updated

to this position in the new commits. The is

updated at the end of the rebase

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.

内容来源: bregman-arie/devops-exercises