治肾虚不含糖,专注内核性能优化二十年。 https://github.com/KnightKu
分类: LINUX
2013-04-23 11:33:23
如果你要查看文件的每个部分是谁修改的, 那么 就是不二选择. 只要运行'git blame [filename]', 你就会得到整个文件的每一行的详细修改信息:包括commit SHA串,日期和作者:
[root@guz linux-2.6]# git blame kernel/cgroup.c ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 1) /* ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 2) * Generic process-grouping system. ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 3) * ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 4) * Based originally on the cpuset system, extracted ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 5) * Copyright (C) 2006 Google, Inc ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 6) * 0dea1168 (Kirill A. Shutemov 2010-03-10 15:22:20 -0800 7) * Notifications support 0dea1168 (Kirill A. Shutemov 2010-03-10 15:22:20 -0800 8) * Copyright (C) 2009 Nokia Corporation 0dea1168 (Kirill A. Shutemov 2010-03-10 15:22:20 -0800 9) * Author: Kirill A. Shutemov 0dea1168 (Kirill A. Shutemov 2010-03-10 15:22:20 -0800 10) * ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 11) * Copyright notices from the original cpuset code: ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 12) * ------------------------------------------------- ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 13) * Copyright (C) 2003 BULL SA. ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 14) * Copyright (C) 2004-2006 Silicon Graphics, Inc. ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 15) * ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 16) * Portions derived from Patrick Mochel's sysfs code ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 17) * sysfs is Copyright (c) 2001-3 Patrick Mochel ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 18) * ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 19) * 2003-10-10 Written by Simon Derr. ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 20) * 2003-10-22 Updates by Stephen Hemminger. ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 21) * 2004 May-July Rework by Paul Jackson. ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 22) * ------------------------------------------------- ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 23) * ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 24) * This file is subject to the terms and conditions ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 25) * License. See the file COPYING in the main direct ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 26) * distribution for more details. ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 27) */ ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 28) ddbcc7e8 (Paul Menage 2007-10-18 23:39:30 -0700 29) #include
如果文件被修改了(reverted),或是编译(build)失败了; 这个命令就可以大展身手了.
你也可以用"-L"参数在命令(blame)中指定开始和结束行:
[root@guz linux-2.6]# git blame -L1400,1410 kernel/cgroup.c cc31edce (Paul Menage 2008-10-18 20:28:04 -0700 1400) { cc31edce (Paul Menage 2008-10-18 20:28:04 -0700 1401) INIT_LIST_HEAD(&cgrp->sibling); cc31edce (Paul Menage 2008-10-18 20:28:04 -0700 1402) INIT_LIST_HEAD(&cgrp->children); 05ef1d7c (Tejun Heo 2012-04-01 12:09:56 -0700 1403) INIT_LIST_HEAD(&cgrp->files); cc31edce (Paul Menage 2008-10-18 20:28:04 -0700 1404) INIT_LIST_HEAD(&cgrp->css_sets); 2243076a (Tejun Heo 2012-11-19 08:13:35 -0800 1405) INIT_LIST_HEAD(&cgrp->allcg_node); cc31edce (Paul Menage 2008-10-18 20:28:04 -0700 1406) INIT_LIST_HEAD(&cgrp->release_list); 72a8cb30 (Ben Blum 2009-09-23 15:56:27 -0700 1407) INIT_LIST_HEAD(&cgrp->pidlists); be445626 (Li Zefan 2013-01-24 14:31:42 +0800 1408) INIT_WORK(&cgrp->free_work, cgroup_free_fn); 72a8cb30 (Ben Blum 2009-09-23 15:56:27 -0700 1409) mutex_init(&cgrp->pidlist_mutex); 0dea1168 (Kirill A. Shutemov 2010-03-10 15:22:20 -0800 1410) INIT_LIST_HEAD(&cgrp->event_list); 更多强大功能参见man git-blame