posts - 35, comments - 0, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          git查看commit的內容

          Posted on 2012-06-13 12:24 timelyxyz 閱讀(215) 評論(0)  編輯  收藏

                在push之前有時候會不放心是不是忘記加某些文件,或者是不是多刪了個什么東西,這時候希望能夠看看上次commit都做了些什么。

          一開始想到的是用git diff,但是git diff用于當前修改尚未commit的時候較為方便,一旦commit后,需要指定上次節(jié)點的名稱(一個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.

          僅僅想看最后一次的提交

          對應命令參數(shù) -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(-)

          想看到最近一次提交所有更改的細節(jié)

          對應命令 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
          from django.core.urlresolvers import reverse
          from django.http import HttpResponseRedirect
          -from django.utils.decorators import available_attrs
          from Site.accounts.models 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的工具可能更直觀些。

           

          原文轉自git使用點滴

           


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導航:
           
          主站蜘蛛池模板: 晋城| 衡东县| 稷山县| 萨迦县| 乐清市| 武乡县| 恩平市| 临澧县| 柳河县| 赣州市| 罗江县| 德州市| 灵山县| 新和县| 伊吾县| 车险| 龙里县| 泸西县| 大冶市| 庆元县| 天镇县| 洛南县| 嘉鱼县| 辽宁省| 文山县| 九台市| 玉树县| 万载县| 正宁县| 金华市| 涪陵区| 河北区| 盘锦市| 新邵县| 佛山市| 墨玉县| 秀山| 阿瓦提县| 浪卡子县| 新河县| 辉南县|