git diff 必须只比较某个偏移量或字符。一行中的列

问题描述 投票:0回答:1

git diff 如何仅从一行中的某个偏移量列进行比较,例如下面的两个日志应该不不同

index 7e2d6d7..cb88ce6
--- a/var/log/lightdm/lightdm.log
+++ b/mnt/OSraw/var/log/lightdm/lightdm.log
@@ -1,46 +1,175 @@

-[+0.00s] DEBUG: Logging to /var/log/lightdm/lightdm.log
-[+0.00s] DEBUG: Starting Light Display Manager 1.32.0, UID=0
-[+0.00s] DEBUG: Loading configuration dirs from /usr/share/lightdm/lightdm.conf.d
-[+0.00s] DEBUG: Loading configuration dirs from /usr/local/share/lightdm/lightdm.conf.d
-[+0.00s] DEBUG: Loading configuration dirs from /etc/xdg/lightdm/lightdm.conf.d
-[+0.00s] DEBUG: Loading configuration from /etc/lightdm/lightdm.conf
-[+0.00s] DEBUG: Registered seat module local

+[+0.01s] DEBUG: Logging to /var/log/lightdm/lightdm.log
+[+0.01s] DEBUG: Starting Light Display Manager 1.32.0, UID=0
+[+0.01s] DEBUG: Loading configuration dirs from /usr/share/lightdm/lightdm.conf.d
+[+0.01s] DEBUG: Loading configuration dirs from /usr/local/share/lightdm/lightdm.conf.d
+[+0.01s] DEBUG: Loading configuration dirs from /etc/xdg/lightdm/lightdm.conf.d
+[+0.01s] DEBUG: Loading configuration from /etc/lightdm/lightdm.conf
+[+0.01s] DEBUG: Registered seat module local

请帮忙!

git compare
1个回答
1
投票

您正在寻找

textconv
差异。虽然文档说它用于区分二进制文件,但“二进制文件”在这里的意思实际上就是任何难以以其原始形式使用的东西。

git config diff.myfilter.textconv "sed 's,^\\[[^]]*] , ,'" 
echo lightdm.log diff=myfilter >> .git/info/attributes

那个

sed
在 diff 看到它们之前将前导括号中的单词从行中删除,只是白掉固定数量的初始列你会做像
s,..........,----------,
.

© www.soinside.com 2019 - 2024. All rights reserved.