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

标签 git git-log

我正在尝试查看自初始提交以来我进行了哪些编辑。

当我从供应商导入和控制代码时,这种情况经常发生。

所以工作流程是这样的:

  1. git add/commit原创
  2. 进行编辑
  3. git commit
  4. 转到2

我想查看自首次创建以来对文件所做的所有更改的记录。

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)
.

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

没有分支 - 也许是一个严重的初始错误,尽管根据我是引入新文件还是编辑现有文件(然后 merge 等)来切换分支会很讨厌

我认为让这件事变得困难的是文件可能随时进入,因此可能会在整个 git 历史记录中添加,所以我认为我不能使用 .. 或各种 revision syntaxes .

似乎是一个简单的用例,但我阅读了 git-log 的文档,并谷歌搜索,没有得到任何结果。

最佳答案

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

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

关于git - 如何使用 git 查看所有文件自初始创建以来的更改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39462616/

相关文章:

git hunk 编辑模式 - 如何删除 '-' 行?

perl - Dreamhost 上的 Gitolite

git - 撤消在 rebase 中完成的 git rerere 解决方案

php - 从 Git 预提交 Hook 上的 STDIN 读取(使用 PHP)

Git 只记录文件的一部分?

linux - git 命令显示来自 sha1 哈希的分支/功能名称

javascript - 如何限制 git 跟踪/更新本地更改?

Git日志解释

git - 如何显示我在所有分支上所做的所有提交?

git - 这个 git log 输出显示了两个分支,就好像它们不是分支一样?请解释