删除最后一次提交
- 查看提交历史
$ git log --oneline
d4417e7 (HEAD -> master) third
911f088 second
32500fa first
- 删除
- 使用
git rebase -i HEAD^
删除
1 pick d4417e7 third # 将pick改为drop, 然后保存
2
3 # Rebase 911f088..d4417e7 onto 911f088 (1 command)
4 #
5 # Commands:
6 # p, pick <commit> = use commit
7 # r, reword <commit> = use commit, but edit the commit message
8 # e, edit <commit> = use commit, but stop for amending
9 # s, squash <commit> = use commit, but meld into previous commit
10 # f, fixup <commit> = like "squash", but discard this commit's log message
11 # x, exec <command> = run command (the rest of the line) using shell
12 # b, break = stop here (continue rebase later with 'git rebase --continue')
13 # d, drop <commit> = remove commit
14 # l, label <label> = label current HEAD with a name
15 # t, reset <label> = reset HEAD to a label
16 # m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
17 # . create a merge commit using the original merge commit's
18 # . message (or the oneline, if no original merge commit was
19 # . specified). Use -c <commit> to reword the commit message.
20 #
21 # These lines can be re-ordered; they are executed from top to bottom.
22 #
23 # If you remove a line here THAT COMMIT WILL BE LOST.
24 #
25 # However, if you remove everything, the rebase will be aborted.
26 #
27 # Note that empty commits are commented out
~
- 使用
git reset --hard HEAD^
查看日志
git log --oneline --decorate
git log stat
git log stat -p