如何使用git查看自初始创建以来所有文件的更改?

时间:2016-09-13 05:16:54

标签: git git-log

我正在尝试查看自初次提交以来我所做的编辑。

当我从供应商导入和控制代码时,会发生很多事情。

所以工作流程是这样的:

  1. git add/commit原始
  2. 进行修改
  3. git commit
  4. 转到2
  5. 我希望看到自首次创建文件以来所有 my 更改的记录。

    git log -p -- <file>不能正常工作,因为文件的初始创建显示为所有行的一个巨大的附加。像这样:

    commit 82abdc4cc52d70dcabdec4b987632f226a1e8bc4
    Author: Greg Bell <greg@>
    Date:   Fri Aug 26 07:13:22 2016 +1000
    
        initial import from vendor
    
    diff --git a/vendor/source.h b/vendor/source.h
    new file mode 100644
    index 0000000..baf6d8a
    --- /dev/null
    +++ b/vendor/source.h
    @@ -0,0 +1,221 @@
    +/*
    + * Error codes returned by blah.
    + *
    + * Copyright (C) 1998-2000 blah blah
    + *
    + * This program is free software; you can redistribute it and/or modify
    + * it under the terms of the GNU General Public License as published by
    + * the Free Software Foundation; either version 3 of the License, or
    + * (at your option) any later version.
    + *
    + * This program is distributed in the hope that it will be useful,
    + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    + * GNU General Public License for more details.
    + *
    + * You should have received a copy of the GNU General Public License along
    + * with this program; if not, visit the http://fsf.org website.
    + */
    
    +#define RERR_OK         0
    +#define RERR_SYNTAX     1       /* syntax or usage error */
    .
    . (all 1250 lines shown)
    .
    

    当我在整个目录上运行日志而不只是一个文件时,这会严重混乱输出。

    没有分支 - 也许是一个关键的初始错误,尽管根据我是引入新文件还是编辑现有文件(然后合并等)来切换分支是很麻烦的。

    我认为这很难使文件可能随时进入,因此可能会在整个git历史记录中添加,因此我认为我不能使用..或各种revision syntaxes。< / p>

    看起来像一个简单的用例,但是我对git-log和Google搜索的文档的阅读并没有产生任何结果。

1 个答案:

答案 0 :(得分:2)

如果我理解正确,您只想查看已制作的修改,并忽略添加新文件。如果这确实是问题,您可以使用--diff-filter开关来限制您想要查看的更改类型,并发送M(修改的简称)参数:

$ git log --diff-filter=M -p -- <file>