git使用点滴:如何查看commit的内容
在push之前有时候会不放心是不是忘记加某些文件,或者是不是多删了个什么东西,这时候希望能够看看上次commit都做了些什么。
一开始想到的是用Git diff,但是git diff用于当前修改尚未commit的时候较为方便,一旦commit后,需要指定上次节点的名称(一个hash值),不方便。这种时候用git log更合适,因为commit的内容会以log来记录。
下面记录几个常用的情境以及对应的命令。
仅仅想看最近谁有提交,以及提交的描述
对应命令 git log
显示Sample
commit 6305aa81a265f9316b606d3564521c43f0d6c9a3
Author: XXX
Date: Thu Nov 3 11:38:15 2011 +0800fill author information in the head of files and format some code
commit 8e8a4a96e134dab8f045937efee35bd710006946
Author: XXX
Date: Thu Nov 3 04:05:34 2011 +0800user management 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 1commit 2870cd564371d8ad043d0da426a5770d36412421
Author: XXX
Date: Mon Oct 17 20:19:04 2011 -0400fix the bug of get_ori_url_from_shorturl().
commit b6cdd881a19ecaff838d5825c3a6b7058fdd498a
Author: XXX
Date: Mon Oct 17 20:17:37 2011 -0400fix the bug of get_article_from_short_url.
仅仅想看最后一次的提交
对应命令参数 -n 1
显示Sample
commit 6305aa81a265f9316b606d3564521c43f0d6c9a3
Author: XXX
Date: Thu Nov 3 11:38:15 2011 +0800fill author information in the head of files and format some code
想看到最近一次提交所有更改过的文件
对应命令 git log -n 1 --stat
显示Sample
commit 6305aa81a265f9316b606d3564521c43f0d6c9a3
Author: XXX
Date: Thu Nov 3 11:38:15 2011 +0800fill author 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 +
……
28 files changed, 37 insertions(+), 8 deletions(-)
想看到最近一次提交所有更改的细节
对应命令 git log -n 1 -p
显示Sample
commit 6305aa81a265f9316b606d3564521c43f0d6c9a3
Author: XXX
Date: Thu Nov 3 11:38:15 2011 +0800fill author information in the head of files and format some code
diff --git a/Site/accounts/decorators.py b/Site/accounts/decorators.py
index 22522bc..a6bb440 100755
--- 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 functools import wraps
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
-from django.utils.decorators import available_attrs
from Site.accounts.models import UserProfiledef login_required(view_func):
diff --git a/Site/accounts/forms.py b/Site/accounts/forms.py
index 016710b..778d92a 100755
--- a/Site/accounts/forms.py
+++ b/Site/accounts/forms.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
+# author: Rex Nov. 3, 201…
…
有了这几条命令,基本上对于想看最近更改的情境就可以应付过去了。最后一条并不很常用,如果有visual的工具可能更直观些。
git使用点滴:如何查看commit的内容的更多相关文章
- Git 撤销所有未提交(Commit)的内容
撸了好多代码,但是突然设计改了(~~o(>_<)o ~~):或者引入个第三方库,后来又发现用不着,想删掉,但文件太多了(比如几百个):那,怎么办呢,都不想了...Git 比人聪明,所以能很 ...
- git修改最后一次commit的内容
提交修改 $ git add test.txt $ git commit -m "提交test.txt文件" 修改注释说明 如果需要修改commit的注释说明,则执行以下命令: $ ...
- 巧用 git rebase 合并多个 commit。
一.为什么需要合并多个 commit 呢? 有时候,我们开发一个功能. 修修补补 commit 了很多次,过多的 commit 会显得很复杂. 不够直观,不能比较清晰查看那些 commit 是对应 ...
- git 查看commit提交的内容
在使用git的过程中,我们经常需要查看某次commit修改了哪些内容,与之相关的命令就是: git log git show 首先,需要通过git log打印所有commit hashID,之后的gi ...
- Git以及github的使用方法(三),git status查看工作区的状态,git diff查看具体修改内容
我们已经成功地添加并提交了一个readme.txt文件,现在,是时候继续工作了,于是,我们继续修改readme.txt文件,改成如下内容: Git is a distributed version c ...
- 【Git】Git如何合并某一次commit的内容到指定分支
一.我是在什么场景下会用到该Git操作 当某同事,将开发分支dev2合并到开发分支dev1时(两个不同的功能,不能合并),其他同事不知情的情况下,继续在dev1上开发并提交了代码. 后面发现了该合并, ...
- Git——快速重命名文件和查看commit提交版本【四】
快速重命名文件 $ git mv README.md readme.md 使用git mv命令后直接commit即可,不再需要进行add或rm操作 查看版本历史 所有的参数都可以进行组合使用的,比如我 ...
- git查看commit提交记录详情
相关的命令: git log:查看所有的commit提交记录: git show: 查看提交的详情: 首先,需要通过git log打印所有commit记录,例如: 1.查看最新的commit:git ...
- Git自动化合并多个Commit
目录 git rebase逻辑 git editor的修改 处理git-rebase-todo文件 Python实现 当我们有多个commit或者从开源处拿到多个commit时,想合成一个commit ...
随机推荐
- 题解 P2762 【太空飞行计划问题】
P2762 太空飞行计划问题 题目描述 W 教授正在为国家航天中心计划一系列的太空飞行.每次太空飞行可进行一系列商业性实验而获取利润.现已确定了一个可供选择的实验集合E={E1,E2,-,Em},和进 ...
- JavaScript中callee与caller,apply与call解析
1. arguments.callee 1.1 解释 返回正被执行的 Function 对象,也就是所指定的 Function 对象的正文. 1,.2 说明 callee 属性的初始值就是正被执行的 ...
- poj 3636
Nested Dolls http://poj.org/problem?id=3636 Time Limit: 1000MS Memory Limit: 65536K Total Submissi ...
- JavaScript之RegExp
分为字面量和RegExp构造函数 1.正则表达式的匹配模式支持3个标志 g:表示全局模式,模式将被应用于所有字符串,而非在发现第一个匹配项时立即停止 i:表示不区分大小写模式,即在确定匹配项时忽略模式 ...
- Python学习笔记(2.1)函数参数练习
关键字参数 和 命名关键字参数 # -*- coding: utf-8 -*- def print_scores(**kw): print(' Name Score') print('-------- ...
- How to Evaluate Machine Learning Models, Part 4: Hyperparameter Tuning
How to Evaluate Machine Learning Models, Part 4: Hyperparameter Tuning In the realm of machine learn ...
- .net core 中 identity server 4 之术语
id4的职责: 保护你的资源 通过本地 账户库(Account Store)或者外部身份提供其 认证用户 提供Session管理以及SSO 管理和认证客户端 发行身份及访问Token给客户端 验证To ...
- DevExpress 常用命令包括导出-打印-打印预览等
3.表格打印也是最常见的,打印代码如下: PrintingSystem ps = null; DevExpress.XtraPrinting.PrintableComponentLink link = ...
- 【BZOJ】3302: [Shoi2005]树的双中心 && 2103: Fire 消防站 && 2447: 消防站
[题意]给定带点权树,要求选择两个点x,y,满足所有点到这两个点中较近者的距离*点权的和最小.n<=50000,h<=100. [算法]树的重心 [题解]代码参考自:cgh_Andy 观察 ...
- Metasploit 进阶
本文是"T00LS Metasploit(第二季)"的文档版,是个人在观看视频动手操作的一个记录,仅供学习.文中会介绍Metasploit的一些基本使用:主要包括远程代码执行.MI ...