git diff只能从某个偏移量或字符进行比较,一行中的列

hrirmatl  于 2023-05-12  发布在  Git
关注(0)|答案(1)|浏览(121)

如何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

请帮帮忙!

4smxwvx5

4smxwvx51#

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

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

sed在diff看到它们之前从行中去掉带括号的单词,只白色固定数量的初始列,您可以执行类似s,..........,----------,的操作。

相关问题