kk Blog —— 通用基础

date [-d @int|str] [+%s|"+%F %T"]

git修改commit

http://blog.chinaunix.net/uid-15007890-id-3220876.html

一、修改最后一次 commit

1
git commit --amend

二、修改再之前 commit

1. 查看之前commit

1
git rebase -i master~5 //最后五次

2. 显示结果如下,把准备修改的commit前面的 pick 改为 edit ,并 :wq 保存退出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
pick 92b4951 2009-08-08: ×××××××
pick 92b4952 2009-08-07: ×××××××
pick 92b4953 2009-08-06: ×××××××
pick 92b4954 2009-08-05: ×××××××
pick 92b4955 2009-08-04: ×××××××

# Rebase 9ef2b1f..92b495b onto 9ef2b1f
#
# Commands:
#  pick = use commit
#  edit = use commit, but stop for amending //改上面的 pick 为 edit
#  squash = use commit, but meld into previous commit
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
#

3. 进行修改

1
2
git commit --amend   # 进行修改,完成后 :wq 退出
git rebase --continue # 完成操作