git查看commit的内容

git查看commit的内容

     push之前有时候会不放心是不是忘记加某些文件,或者是不是多删了个什么东西,这时候希望能够看看上次commit都做了些什么。

一开始想到的是用gitdiff,但是gitdiff用于当前修改尚未commit的时候较为方便,一旦commit后,需要指定上次节点的名称(一个hash值),不方便。这种时候用gitlog更合适,因为commit的内容会以log来记录。

下面记录几个常用的情境以及对应的命令。

仅仅想看最近谁有提交,以及提交的描述

对应命令 gitlog

显示Sample

 

commit6305aa81a265f9316b606d3564521c43f0d6c9a3 
Author:XXX 
Date:   Thu Nov 3 11:38:15 2011 +0800
    fillauthor information in the head of files and format some code
commit8e8a4a96e134dab8f045937efee35bd710006946 
Author:XXX 
Date:   Thu Nov 3 04:05:34 2011 +0800
    usermanagement is mostly complete
    details: 
   add support for account disable/enable 
   rewrite most related views to suit the above need 
   provide two decorators for access control (see README) 
   fixed many errors in Milestone 1
commit2870cd564371d8ad043d0da426a5770d36412421 
Author:XXX 
Date:   Mon Oct 17 20:19:04 2011 -0400
    fixthe bug of get_ori_url_from_shorturl().
commitb6cdd881a19ecaff838d5825c3a6b7058fdd498a 
Author:XXX 
Date:   Mon Oct 17 20:17:37 2011 -0400
    fixthe bug of get_article_from_short_url.

仅仅想看最后一次的提交

对应命令参数-n1

显示Sample

commit6305aa81a265f9316b606d3564521c43f0d6c9a3 
Author: XXX 
Date:Thu Nov 3 11:38:15 2011 +0800
fillauthor information in the head of files and format some code

想看到最近一次提交所有更改过的文件

对应命令 gitlog -n 1 --stat

显示Sample

commit6305aa81a265f9316b606d3564521c43f0d6c9a3 
Author:XXX 
Date:   Thu Nov 3 11:38:15 2011 +0800
    fillauthor information in the head of files and format some code
Site/accounts/decorators.py                       |    2+- 
Site/accounts/forms.py                            |    1+ 
Site/accounts/models.py                           |    1+ 
Site/accounts/readme                              |    3++- 
Site/accounts/templates/account_activate.html     |    1+ 
Site/accounts/templates/account_disabled.html     |    1 + 
28files changed, 37 insertions(+), 8 deletions(-)

想看到最近一次提交所有更改的细节

对应命令 gitlog -n 1 -p

显示Sample

commit6305aa81a265f9316b606d3564521c43f0d6c9a3 
Author:XXX 
Date:   Thu Nov 3 11:38:15 2011 +0800
    fillauthor information in the head of files and format some code
diff--git a/Site/accounts/decorators.pyb/Site/accounts/decorators.py 
index 22522bc..a6bb440100755 
--- a/Site/accounts/decorators.py 
+++b/Site/accounts/decorators.py 
@@ -1,9 +1,9@@ 
#!/usr/bin/env python 
# -*- coding: utf-8-*- 
+# author: Rex Nov. 3, 2011 
from functoolsimport wraps 
from django.core.urlresolvers importreverse 
from django.http import HttpResponseRedirect 
-fromdjango.utils.decorators import available_attrs 
fromSite.accounts.models import UserProfile
deflogin_required(view_func): 
diff --gita/Site/accounts/forms.py b/Site/accounts/forms.py 
index016710b..778d92a 100755 
--- a/Site/accounts/forms.py 
+++b/Site/accounts/forms.py 
@@ -1,5 +1,6 @@ 
#!/usr/bin/envpython 
# -*- coding: utf-8 -*- 
+# author: Rex Nov.3, 201

有了这几条命令,基本上对于想看最近更改的情境就可以应付过去了。最后一条并不很常用,如果有visual的工具可能更直观些。


  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
查看gitcommit,可以使用以下方法: 1. 使用git bash命令行工具,可以通过以下命令查看你自己提交的commit记录并获取对应的commit ID: ``` git log --author="账号名字" ``` 2. 使用git bash命令行工具,可以通过以下命令查看指定commit ID提交的代码: ``` git show commitID ``` 3. 如果你有一个已解压的package文件夹,你可以通过以下步骤使用git bash命令行工具: - 进入package文件夹,右键点击打开git bash。 - 执行以下命令来运行install.sh脚本: ``` sh install.sh ``` 4. 如果你已经在一个git仓库中,可以通过以下步骤来查看commit记录和具体的提交内容: - 执行以下命令来初始化git仓库(如果还没有初始化): ``` git init ``` - 通过以下命令查看当前分支的commit记录以及对应的commit ID: ``` git log ``` - 在branch中选择对应的分支,点击要查看commit的ID,进入commit查看commit点的内容。 综上所述,你可以使用以上方法来查看gitcommit记录和具体的提交内容。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [如何查看github中的commit内容](https://blog.csdn.net/ljl86400/article/details/79359684)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [gitcommit模板及commit规范校验工具一键安装](https://download.csdn.net/download/qq_31900283/86398933)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值