git命令的使用(二)

日常开发工作中,代码库是程序员关注最多的资源,不论是代码入库,版本发布,还是bug修复,都离不开代码库。代码库的每次提交变动,关系到版本的正常发布。
为了查看某次提交或者某个文件的改动记录,下面介绍几个命令。

查看某次提交的修改内容

$ git show commit-id

$ git show 6454f159e3642b361f8e

commit 6454f159e3642b361f8ea6afe22c3f264f768b9b
Author: lanyang<lanyang@gmail.com>
Date:   Fri Oct 28 16:45:24 2016 +0800

    206

diff --git a/3.txt b/3.txt
index 00750ed..f4540d5 100644
--- a/3.txt
+++ b/3.txt
@@ -1 +1,2 @@
 3
+206

查看所有提交的修改内容

$ git log -p
查看最近两次提交修改的内容

$ git log -p -2

查看某个文件或目录的修改记录

$ git log -p < file name or directory name>

$ git log -p 1.txt
commit 29c23277f5e306c7514d393781d35e62efe82265
Author: lanyang<lanyang@gmail.com>
Date:   Fri Oct 28 18:03:57 2016 +0800

    commit not push now2

diff --git a/1.txt b/1.txt
index d77212f..cdc1ca1 100644
--- a/1.txt
+++ b/1.txt
@@ -5,3 +5,4 @@ helloworld
 12222
 hello
 commit not push now1
+commit not push now2

commit 75a33de417f3fceb5b0af10f1f13460e6495f9d2
Author: lanyang<lanyang@gmail.com>
Date:   Fri Oct 28 18:03:37 2016 +0800

    commit not push now1

diff --git a/1.txt b/1.txt
index e37ce3c..d77212f 100644
--- a/1.txt
+++ b/1.txt
@@ -4,3 +4,4 @@ helloworld
 21
 12222
 hello
+commit not push now1

小结:

本文主要介绍代码库提交记录及文件修改记录的查看方式。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值