我正在尝试查看自初始提交以来我进行了哪些编辑。
当我从供应商导入和控制代码时,这种情况经常发生。
所以工作流程是这样的:
-
git add/commit
原创 - 进行编辑
-
git commit
- 转到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/