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 +0800
fill author information in the head of files and format some code
commit 8e8a4a96e134dab8f045937efee35bd710006946
Author: XXX
Date:  Thu Nov 3 04:05:34 2011 +0800
user 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 1
commit 2870cd564371d8ad043d0da426a5770d36412421
Author: XXX
Date:  Mon Oct 17 20:19:04 2011 -0400
fix the bug of get_ori_url_from_shorturl().
commit b6cdd881a19ecaff838d5825c3a6b7058fdd498a
Author: XXX
Date:  Mon Oct 17 20:17:37 2011 -0400
fix the bug of get_article_from_short_url.
仅仅想看最后⼀次的提交
对应命令参数 -n 1
显⽰Sample
commit 6305aa81a265f9316b606d3564521c43f0d6c9a3
Author: XXX
Date: Thu Nov 3 11:38:15 2011 +0800
fill 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 +0800
fill 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 +0800
fill 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
urlresolvers import reverse
from django.http import HttpResponseRedirect
-from django.utils.decorators import available_attrs
from dels import UserProfile
def 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的⼯具可能更直观些。原⽂转⾃

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。