Git权威指南--改变历史

来源:互联网 发布:网络日语培训班 编辑:程序博客网 时间:2024/05/18 02:16

2.多步悔棋

0.查看版本库最新五次提交

$ git log --stat --oneline -5e2609ca 加结束标志 test_git.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)1f5c128 此处省略一万字 test_git.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)306b97b 增加修改时间 test_git.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)0c30d3e 增加修改人 test_git.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)07cab98 新增测试文件 test_git.txt | 1 + 1 file changed, 1 insertion(+)

将最近两次提交合二为一,并把提交说明改为“增加修改时间......”

1.使用--soft 参数 调用重置命令,回到最近两次提交之前

$ git reset --soft HEAD^^

2.查看版本库最新提交

$ git log -1commit 306b97b5dc629cb428d664c50f31f7815ad370f0Author: yinnana <nanayin@creditease.cn>Date:   Wed Feb 8 13:14:10 2017 +0800    增加修改时间

3.执行提交操作,即完成最新两个提交压缩为一个提交的操作

$ git commit -m "增加修改时间......"[master 060a9f4] 增加修改时间...... 1 file changed, 3 insertions(+), 1 deletion(-)

4.查看提交日志,验证

$ git log --stat --oneline -5060a9f4 增加修改时间...... test_git.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)306b97b 增加修改时间 test_git.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)0c30d3e 增加修改人 test_git.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)07cab98 新增测试文件 test_git.txt | 1 + 1 file changed, 1 insertion(+)66a5a9b modify test.txt test.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)


3.回到未来


涉及到的:拣选操作、变基操作、交互式变基操作

3.1  去除提交 D

0)对提交进行标识

$ git tag F$ git tag E HEAD^$ git tag D HEAD~2$ git tag C HEAD~3$ git tag B HEAD~4$ git tag A HEAD~5
通过日志,可以看到被标记的六个提交

$ git log --oneline --decorate -62cbfc1b (HEAD -> master, tag: F) 添加正文e869230 (tag: E) 编辑文本内容6080809 (tag: D) 删除 注意事项!!f94e582 (tag: C) 注意事项1af8a1c5 (tag: B) 添加 注意事项060a9f4 (tag: A) 增加修改时间......

1)执行git checkout ,暂时将HEAD头指针切换到C(切换过程中显示出于非跟踪状态的警告)

$ git checkout CNote: checking out 'C'.You are in 'detached HEAD' state. You can look around, make experimentalchanges and commit them, and you can discard any commits you make in thisstate without impacting any branches by performing another checkout.If you want to create a new branch to retain commits you create, you maydo so (now or later) by using -b with the checkout command again. Example:  git checkout -b <new-branch-name>HEAD is now at f94e582... 注意事项1
$ git log --oneline --decorate -6f94e582 (HEAD, tag: C) 注意事项1af8a1c5 (tag: B) 添加 注意事项060a9f4 (tag: A) 增加修改时间......306b97b 增加修改时间0c30d3e 增加修改人07cab98 新增测试文件

2)执行拣选操作将E提交在当前HEAD上重放。

因为E和master^显然指向同一指向,因此可以用如下语法。

$ git cherry-pick master^[detached HEAD d8862cb] 编辑文本内容 Date: Wed Feb 8 13:32:28 2017 +0800 1 file changed, 1 insertion(+), 1 deletion(-)

3)执行拣选操作将F提交在当前HEAD上重放

F和master指向同一指向

$ git cherry-pick master[detached HEAD 5883cdd] 添加正文 Date: Wed Feb 8 13:33:14 2017 +0800 1 file changed, 3 insertions(+)

4)通过日志看到D不存在了

$ git log --oneline --decorate -65883cdd (HEAD) 添加正文d8862cb 编辑文本内容f94e582 (tag: C) 注意事项1af8a1c5 (tag: B) 添加 注意事项060a9f4 (tag: A) 增加修改时间......306b97b 增加修改时间

5)通过日志可以看出,最近两次提交的原始创作日期(AuthorDate)和提交日期(CommitDate)不同。

AuthorDate是拣选提交的原始更改时间,CommitDate是拣选操作的时间

$ git log --pretty=fuller --decorate -3commit 5883cddb3b5d8f5a88aec7eb1ce1ff616a9606e4 (HEAD)Author:     yinnana <nanayin@creditease.cn>AuthorDate: Wed Feb 8 13:33:14 2017 +0800Commit:     yinnana <nanayin@creditease.cn>CommitDate: Wed Feb 8 14:00:40 2017 +0800    添加正文commit d8862cbb1913ced14ce4c9441204019965751567Author:     yinnana <nanayin@creditease.cn>AuthorDate: Wed Feb 8 13:32:28 2017 +0800Commit:     yinnana <nanayin@creditease.cn>CommitDate: Wed Feb 8 13:58:16 2017 +0800    编辑文本内容commit f94e582809f7cc05bf5e8c9950dd32ebc4ac6ac4 (tag: C)Author:     yinnana <nanayin@creditease.cn>AuthorDate: Wed Feb 8 13:30:53 2017 +0800Commit:     yinnana <nanayin@creditease.cn>CommitDate: Wed Feb 8 13:30:53 2017 +0800    注意事项1

6)将master分支重置到新的提交ID(5883cdd)上

下面的切换操作使用了reflog的语法,即HEAD@{1}相当于切换回master分支前的HEAD指向

$ git checkout masterWarning: you are leaving 2 commits behind, not connected toany of your branches:  5883cdd 添加正文  d8862cb 编辑文本内容If you want to keep them by creating a new branch, this may be a good timeto do so with: git branch <new-branch-name> 5883cdd

$ git reset --hard HEAD@{1}HEAD is now at 5883cdd 添加正文


比较

2cbfc1b (HEAD -> master, tag: F) 添加正文
e869230 (tag: E) 编辑文本内容
6080809 (tag: D) 删除 注意事项!!
f94e582 (tag: C) 注意事项1
af8a1c5 (tag: B) 添加 注意事项
060a9f4 (tag: A) 增加修改时间......


后**********
5883cdd (HEAD -> master) 添加正文
d8862cb 编辑文本内容
f94e582 (tag: C) 注意事项1
af8a1c5 (tag: B) 添加 注意事项
060a9f4 (tag: A) 增加修改时间......
306b97b 增加修改时间


3.2 合并 提交CD

0)将master分支重新置回到提交F上
$ git checkout masterAlready on 'master'
$ git reset --hard FHEAD is now at 2cbfc1b 添加正文
$ git log --oneline --decorate -62cbfc1b (HEAD -> master, tag: F) 添加正文e869230 (tag: E) 编辑文本内容6080809 (tag: D) 删除 注意事项!!f94e582 (tag: C) 注意事项1af8a1c5 (tag: B) 添加 注意事项060a9f4 (tag: A) 增加修改时间......

1)暂时将HEAD头指针切换到D
$ git checkout DNote: checking out 'D'.You are in 'detached HEAD' state. You can look around, make experimentalchanges and commit them, and you can discard any commits you make in thisstate without impacting any branches by performing another checkout.If you want to create a new branch to retain commits you create, you maydo so (now or later) by using -b with the checkout command again. Example:  git checkout -b <new-branch-name>HEAD is now at 6080809... 删除 注意事项!!

2)悔棋两次,以便将C和D融合
$ git reset --soft HEAD^^
$ git log --oneline --decorate -6af8a1c5 (HEAD, tag: B) 添加 注意事项060a9f4 (tag: A) 增加修改时间......306b97b 增加修改时间0c30d3e 增加修改人07cab98 新增测试文件66a5a9b modify test.txt

3)提交,重用提交C的提交说明
$ git commit -C C[detached HEAD 670829a] 注意事项1 Date: Wed Feb 8 13:30:53 2017 +0800 1 file changed, 1 insertion(+), 1 deletion(-)

4)执行拣选操作将E提交在当前HEAD上重放
$ git cherry-pick E[detached HEAD 133d8cf] 编辑文本内容 Date: Wed Feb 8 13:32:28 2017 +0800 1 file changed, 1 insertion(+), 1 deletion(-)

5)执行拣选操作将F提交在当前HEAD上重放
$ git cherry-pick F[detached HEAD 2642edf] 添加正文 Date: Wed Feb 8 13:33:14 2017 +0800 1 file changed, 3 insertions(+)

6)通过日志看到提交C和D融合,所以在日志中看不到C的标签
$ git log --oneline --decorate -62642edf (HEAD) 添加正文133d8cf 编辑文本内容670829a 注意事项1af8a1c5 (tag: B) 添加 注意事项060a9f4 (tag: A) 增加修改时间......306b97b 增加修改时间

7)将master分支指向新的提交ID(2642edf)
下面的切换操作使用了reflog的语法,即HEAD@{1}相当于切换回master分支前的HEAD指向
$ git checkout masterWarning: you are leaving 3 commits behind, not connected toany of your branches:  2642edf 添加正文  133d8cf 编辑文本内容  670829a 注意事项1If you want to keep them by creating a new branch, this may be a good timeto do so with: git branch <new-branch-name> 2642edfSwitched to branch 'master'
$ git reset --hard HEAD@{1}HEAD is now at 2642edf 添加正文
$ git log --oneline --decorate -62642edf (HEAD -> master) 添加正文133d8cf 编辑文本内容670829a 注意事项1af8a1c5 (tag: B) 添加 注意事项060a9f4 (tag: A) 增加修改时间......306b97b 增加修改时间


3.3 rebase 变基操作

0)将master分支重新置回到提交F上
$ git checkout masterAlready on 'master'
$ git reset --hard FHEAD is now at 2cbfc1b 添加正文

git rebase 可以实现将指定范围的提交 嫁接到另一个提交之上
命令格式:
用法1:git rebase --onto <newbase><since><till>
用法2:git rebase --onto <newbase><since>
用法3:git rebase <since><till>
用法4:git rebase  <since>
用法5:git rebase  -i ...
用法6:git rebase --continue
用法7:git rebase --skip
用法8:git rebase --abort

用法6是在变基遇到冲突而暂停的情况下,先完成冲突解决(添加到暂存区,不提交),然后在恢复变基操作的时候使用该命令。

用法7是在变基遇到冲突而暂停的情况下,跳过当前提交的时候使用。

用法8是在变基遇到冲突而暂停的情况下,终止变基操作,回到之前的分支时候使用。


用法1为例,其用法如下:

git rebase --onto <newbase><since><till>

1.首先会执行 git checkout 切换到 <till>

如果<till>指向 的不是一个分支(如master),则变基操作是在 detached HEAD(分离头指针)状态进行的,

当变基结束后,像上述3.1那样,对master分支执行重置以实现变基结果在分支中生效。

2.将<since>...<till>所标识的提交范围写到一个临时文件中

包括<till>的所有历史提交排除<since>及<since>的历史提交后形成的版本范围

3.将当前分支强制重置(git reset --hard)到<newbase>

相当于执行git reset --hard <newbase>

4.从保存在临时文件中的提交列表中,将提交逐一按顺序重新提交到重置之后的分支上

5.如果遇到提交已经在分支中包含,则跳过该提交

6.如果在提交过程中遇到冲突,则变基过程暂停。

用户解决冲突后,执行 git rebase --continue 继续变基操作,

或者执行 git rebase --skip跳过此提交,

或执行 git rebase --abort就此终止变基操作切换到当前变基前的分支上


为了执行将E和F提交跳过提交D,嫁接到提交C上,可以执行如下变基命令:

git rebase --onto C E^ F

因为 E^ 等价于D,并且F和当前HEAD的指向相同,因此可以这样:

git rebase --onto C D


$ git status -s -b## master
$ git log --oneline --decorate -62cbfc1b (HEAD -> master, tag: F) 添加正文e869230 (tag: E) 编辑文本内容6080809 (tag: D) 删除 注意事项!!f94e582 (tag: C) 注意事项1af8a1c5 (tag: B) 添加 注意事项060a9f4 (tag: A) 增加修改时间......

第一幕,去除D

1.变基操作

因为F是一个里程碑指向一个提交,而非master,所以后面变基完成后还需要对master分支进行重置

$ git rebase --onto C E^ FFirst, rewinding head to replay your work on top of it...Applying: 编辑文本内容Using index info to reconstruct a base tree...M       test_git.txtFalling back to patching base and 3-way merge...Auto-merging test_git.txtApplying: 添加正文Using index info to reconstruct a base tree...M       test_git.txtFalling back to patching base and 3-way merge...Auto-merging test_git.txt


2.将master分支指向变基后的提交

$ git checkout masterWarning: you are leaving 2 commits behind, not connected toany of your branches:  071b3b2 添加正文  c57a3ba 编辑文本内容If you want to keep them by creating a new branch, this may be a good timeto do so with: git branch <new-branch-name> 071b3b2Switched to branch 'master'
$ git reset --hard HEAD@{1}HEAD is now at 071b3b2 添加正文


3.检查

$ git log --oneline --decorate -6071b3b2 (HEAD -> master) 添加正文c57a3ba 编辑文本内容f94e582 (tag: C) 注意事项1af8a1c5 (tag: B) 添加 注意事项060a9f4 (tag: A) 增加修改时间......306b97b 增加修改时间


第二幕准备

$ git status -s -b## master
$ git reset --hard FHEAD is now at 2cbfc1b 添加正文


第二幕,CD融合

1.暂时将HEAD头指针切换到D

$ git checkout DNote: checking out 'D'.You are in 'detached HEAD' state. You can look around, make experimentalchanges and commit them, and you can discard any commits you make in thisstate without impacting any branches by performing another checkout.If you want to create a new branch to retain commits you create, you maydo so (now or later) by using -b with the checkout command again. Example:  git checkout -b <new-branch-name>HEAD is now at 6080809... 删除 注意事项!!

2.悔棋两次,以便将C和D融合

$ git reset --soft HEAD^^


3.执行提交,提交说明重用C提交的提交说明

$ git commit -C C[detached HEAD e4e3bdb] 注意事项1 Date: Wed Feb 8 13:30:53 2017 +0800 1 file changed, 1 insertion(+), 1 deletion(-)

4.记住这个提交ID

$ git tag newbase
$ git rev-parse newbasee4e3bdbc1ac6592b5f006fc88ab7920e9ccc98c4


5.执行编辑操作,将EF提交嫁接到newbase上

下面的变基操作命令没有像之前的操作那样使用参数F,而是使用分支master,

所以接下来的变基操作会直接修改master分支,而无须再对master进行重置

$ git rebase --onto newbase E^ masterFirst, rewinding head to replay your work on top of it...Applying: 编辑文本内容Applying: 添加正文


6.看看提交日志,提交CD都不见了,代之以融合后的提交newbase

还可以看到最新的提交除了和HEAD的指向一致,也和master分支的指向一致

$ git log --oneline --decorate -6e8d1cc7 (HEAD -> master) 添加正文9a5e18a 编辑文本内容e4e3bdb (tag: newbase) 注意事项1af8a1c5 (tag: B) 添加 注意事项060a9f4 (tag: A) 增加修改时间......306b97b 增加修改时间

7.确保当前的确在master分支上

$ git branch* master


为下一步准备

$ git tag -d newbaseDeleted tag 'newbase' (was e4e3bdb)
$ git branch* master
$ git checkout masterAlready on 'master'
$ git reset --hard FHEAD is now at 2cbfc1b 添加正文


3.3交互式变基

在上一节的变基命令的基础上,添加 -i 参数,在变基的时候进入一个交互界面
执行交互式变基操作,会将<since>..<till>的提交悉数罗列在一个文件中,然后自动打开一个编辑器来编辑这个文件。
可以通过修改文件的内容设定变基操作,实现删除提交、将多个提交压缩为一个提交、更改提交的顺序,以及更改历史提交的提交说明。
$ git status -s -b## master
$ git log --oneline --decorate -62cbfc1b (HEAD -> master, tag: F) 添加正文e869230 (tag: E) 编辑文本内容6080809 (tag: D) 删除 注意事项!!f94e582 (tag: C) 注意事项1af8a1c5 (tag: B) 添加 注意事项060a9f4 (tag: A) 增加修改时间......


3.3.1干掉D

1.执行交互式变基操作
$ git rebase -i D^

2.自动用编辑器修改文件,将第一行删除,保存退出
变基自动开始,即可完成,显示如下内容:
Successfully rebased and updated refs/heads/master.

3.查看提交日志,当前分支master已经完成变基,消灭了D
$ git log --oneline --decorate -6a1630be (HEAD -> master) 添加正文7512a7b 编辑文本内容f94e582 (tag: C) 注意事项1af8a1c5 (tag: B) 添加 注意事项060a9f4 (tag: A) 增加修改时间......306b97b 增加修改时间


3.3.2 融合CD

0.准备工作
$ git checkout masterAlready on 'master'
$ git reset --hard FHEAD is now at 2cbfc1b 添加正文

1.同样执行交互式变基操作,不过因为要将CD压缩为一个,因此变基从C的父提交开始
$ git rebase -i C^

2.自动用编辑器修改文件,文件内容如下:
pick f94e582 注意事项1pick 6080809 删除 注意事项!!pick e869230 编辑文本内容pick 2cbfc1b 添加正文# Rebase af8a1c5..2cbfc1b onto af8a1c5 (4 command(s))## 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 = like "squash", but discard this commit's log message# x, exec = run command (the rest of the line) using shell# d, drop = remove commit## 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.#

3.修改提交D,将动作由pick修改为squash
pick f94e582 注意事项1squash 6080809 删除 注意事项!!pick e869230 编辑文本内容pick 2cbfc1b 添加正文

4.保存退出,自动开始变基操作,在执行squash命令设定的提交时,进入提交前的日志编辑状态
显示的待编辑日志如下,很明显C和D的提交说明显示在一起了
# This is a combination of 2 commits.# The first commit's message is:注意事项1# This is the 2nd commit message:删除 注意事项!!# Please enter the commit message for your changes. Lines starting# with '#' will be ignored, and an empty message aborts the commit.## Date:      Wed Feb 8 13:30:53 2017 +0800## interactive rebase in progress; onto af8a1c5# Last commands done (2 commands done):#    pick f94e582 注意事项1#    squash 6080809 删除 注意事项!!# Next commands to do (2 remaining commands):#    pick e869230 编辑文本内容#    pick 2cbfc1b 添加正文

5.保存退出,即完成squash动作标识的提交合并及后续变基操作
[detached HEAD 09f44e7] 注意事项1 Date: Wed Feb 8 13:30:53 2017 +0800 1 file changed, 1 insertion(+), 1 deletion(-)Successfully rebased and updated refs/heads/master.
查看提交日志,看到提交CD都不见了,代之以一个融合后的提交出现
$ git log --oneline --decorate -67d81b62 (HEAD -> master) 添加正文6f6affd 编辑文本内容09f44e7 注意事项1af8a1c5 (tag: B) 添加 注意事项060a9f4 (tag: A) 增加修改时间......306b97b 增加修改时间

6.可以看到融合C和D的提交日志实际上是两者日志的融合,在前面单行显示的日志中看不出来
$ git cat-file -p HEAD^^tree b0c78e64caa337d0e7b25f92fcc0b6cc368dc278parent af8a1c5945157cbe38c15a45ef5a78e654c10404author yinnana <nanayin@creditease.cn> 1486531853 +0800committer yinnana <nanayin@creditease.cn> 1486885137 +0800注意事项1删除 注意事项!!



4.丢弃历史

$ git log --oneline --decorate7d81b62 (HEAD -> master) 添加正文6f6affd 编辑文本内容09f44e7 注意事项1af8a1c5 (tag: B) 添加 注意事项060a9f4 (tag: A) 增加修改时间......306b97b 增加修改时间0c30d3e 增加修改人07cab98 新增测试文件66a5a9b modify test.txtb6e2840 reset test40bcec0 clean workfece0be 偷懒了,直接使用-a参数直接提交a1158c1 add yin.do0642531 hello world initiallized631d7aa README is from welcome.txt2c5da85 restore file:welcome.txt4107309 delete trashj file.(using: git add -u)19d2c13 welcome txt45ad43e commit '62e5' test62e5a6a commit in detached HEAD mode63335a1 does master follow this new commit?df33bea test1492478d test268afa3 testdf69eb9 initialized

如果希望把里程碑A(060a9f4)之前的历史提交全部清除,可以这样操作:

基于里程碑A对应的提交构造一个根提交(即没有父提交的提交),

然后再将master分支在里程碑A之后的提交变基到新的根提交上,实现对历史提交的清除

 由里程碑A对应的提交构造出一个根提交至少有两种方法,

第一种方法使用git commit-tree命令

1.查看里程碑A指向的目录树

$ git cat-file -p A^{tree}100644 blob 07ec8c0d8cbc786902a1bf75110bbd65faf039e4    test.txt100644 blob 0e36841a956fee58881a8777b6ddba960e6a9aee    test_git.txt


2.使用git commit-tree 命令直接从该目录树创建提交

$ echo "commit from tree of tag A." | git commit-tree A^{tree}655585e59d659258aebe88c3af39a72d6cb92d5d
$ git log --pretty=raw 655585commit 655585e59d659258aebe88c3af39a72d6cb92d5dtree f7b0e74916729417a5f2938161512ee2add5faf6author yinnana <nanayin@creditease.cn> 1486886037 +0800committer yinnana <nanayin@creditease.cn> 1486886037 +0800    commit from tree of tag A.


第二种方法 使用git hash-object命令,从里程碑A指向的提交建立一个根提交

1.查看里程碑A指向的提交

A^0语法访问里程碑A对应的提交

$ git cat-file commit A^0tree f7b0e74916729417a5f2938161512ee2add5faf6parent 306b97b5dc629cb428d664c50f31f7815ad370f0author yinnana <nanayin@creditease.cn> 1486531605 +0800committer yinnana <nanayin@creditease.cn> 1486531605 +0800增加修改时间......

2.将上面的输出过滤掉以parent开头的行,并将结果保存到一个文件中

$ git cat-file commit A^0 | sed -e '/^parent/ d' > tmpfile

3.运行git hash-object 命令,将文件tmpfile作为一个commit对象写入到对象库

$ git hash-object -t commit -w -- tmpfile1dd6790f427a0e40b915fafd3a8743beffbadde7

4.上述输出结果就是写入git对象库中的新的提交对象ID

$ git log --pretty=raw 1dd679commit 1dd6790f427a0e40b915fafd3a8743beffbadde7tree f7b0e74916729417a5f2938161512ee2add5faf6author yinnana <nanayin@creditease.cn> 1486531605 +0800committer yinnana <nanayin@creditease.cn> 1486531605 +0800    增加修改时间......


不管上述哪种方法创建新的根提交后,就可以执行变基操作,

将master分支在里程碑A之后的提交变基到新的根提交上

1.执行变基,将master分支里程碑A之后的提交全部迁移到根提交1dd679上

$ git rebase --onto 1dd679 A masterFirst, rewinding head to replay your work on top of it...Applying: 添加 注意事项Applying: 注意事项1Applying: 编辑文本内容Applying: 添加正文

2.查看日志看到当前master分支的历史已经精简了

$ git log --oneline --decorate2983632 (HEAD -> master) 添加正文2e0a295 编辑文本内容d1af590 注意事项1123b9ef 添加 注意事项1dd6790 增加修改时间......


5.反转提交 git revert

如果多人协同使用git,在本地版本库做的提交会通过多人之间的交互成为他人版本库的一部分,更改历史操作只能是针对自己的版本库,而无法去修改他人的版本库

这种情况下,想修正一个错误历史提交的正确做法是反转提交,即重新做一次新的提交,相当于用错误的历史提交的反向提交,来修正错误的历史提交

$ git show HEADcommit 29836323a44359dd41667dbcb4f19d842e4bcf56Author: yinnana <nanayin@creditease.cn>Date:   Wed Feb 8 13:33:14 2017 +0800    添加正文diff --git a/test_git.txt b/test_git.txtindex 424e6d8..6067962 100644--- a/test_git.txt+++ b/test_git.txt@@ -1,7 +1,10 @@

在不改变这个提交的前提下撤销对其的修改,

$ git revert HEAD
[master e0ab391] Revert "添加正文" 1 file changed, 3 deletions(-)
该命令相当于将HEAD提交反向再提交一次,在提交说明编辑状态下暂停,显示如下:

$ git log --stat -2commit e0ab3913fd8ea84e7c397a38996a213feee31e34Author: yinnana <nanayin@creditease.cn>Date:   Sun Feb 12 16:12:01 2017 +0800    Revert "添加正文"    This reverts commit 29836323a44359dd41667dbcb4f19d842e4bcf56. test_git.txt | 3 --- 1 file changed, 3 deletions(-)commit 29836323a44359dd41667dbcb4f19d842e4bcf56Author: yinnana <nanayin@creditease.cn>Date:   Wed Feb 8 13:33:14 2017 +0800    添加正文 test_git.txt | 3 +++ 1 file changed, 3 insertions(+)














0 0
原创粉丝点击