在 git show/git diff 中将 tabwidth 设置为 4 [英] setting tabwidth to 4 in git show / git diff

查看:9
本文介绍了在 git show/git diff 中将 tabwidth 设置为 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在工作中,我们是几个开发人员,没有代码样式指南,一些开发人员使用制表符缩进,而另一些开发人员使用 4 个空格(幸运的是,没有人使用不同于 4 个空格的空格缩进).一般来说,这不是(大)问题,因为在我们的编辑器中我们设置了 tabwidth=4 并且所有缩进看起来都是正确的.

At work we are several developers and don't have a code style guide, and some developers indent with tabs, and some others with 4 spaces (luckily noone of the indent with spaces people uses different than 4 spaces). In general this is no (big) problem because in our editors we set tabwidth=4 and all the indentation seems correct.

但在 git diffgit show 中会出现这样的情况:

But in git diff or git show that's what appears:

diff --git a/mesclatabs.php b/mesclatabs.php
new file mode 100644
index 0000000..1986c91
--- /dev/null
+++ b/mesclatabs.php
@@ -0,0 +1,5 @@
+<?php
+function foo() {
+       echo "line with 1 tab
";
+    echo "line with 4 spaces
";
+}

问题是 git diffgit show 每个选项卡显示为 8 个空格(好吧,实际上显示为一个选项卡,而 shell(bash 在我的情况)正在将选项卡显示为 8 个空格.我想必须有一些 bash 配置来更改它,但我想知道 git 是否可以选择在 diff 中将选项卡输出为 4 个空格/show,因为一些开发人员使用 zsh 而不是 bash.

The problem is git diff or git show where each tabs appears as wide as 8 spaces (well, in reality appears as a tab, and the shell (bash in my case) is showing the tab as 8 spaces. I suppose there must be some bash config to change this, but I'd like to know if git has an option to output tabs as 4 spaces in diff / show, as some developers work with zsh instead of bash.

有什么想法吗?

推荐答案

我相信 git config --global core.pager 'less -x1,5'

参考资料:

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆