git diff 修改_如何自定义git diff以更快地发现更改

git diff 修改

git diff is one of the most useful features in git. Customizing diff will make your life easier.

git diff是git中最有用的功能之一。 自定义差异将使您的生活更轻松。

Diff-so-fancy is the git tool that helps you to make good looking diffs. This tool helps you to spot the differences without any human error.

Diff-so-fancy是git工具,可帮助您制作美观的diff。 该工具可帮助您发现差异而不会出现任何人为错误。

You can view the package in this repo

您可以在此仓库中查看软件包

Let’s see that in-depth

让我们深入了解

安装 (Installation)

Diff-so-fancy is available in brew, npm and also as a package for Debian Linux

Diff-so-fancy可在brew,npm中使用,也可以作为Debian Linux的软件包使用。

brew install diff-so-fancy npm i diff-so-fancy --global

用法 (Usage)

I will explain a few ways of using diff-so-fancy. You can choose your way of doing it.

我将解释几种使用diff-so-fancy的方法。 您可以选择自己的方式。

Be default, diff-so-fancy will never change any default diff options. You should explicitly mention it.

默认情况下,diff-so-fancy将永远不会更改任何默认的diff选项。 您应该明确提及它。

git diff | diff-so-fancy

The above command will use diff-so-fancy to display the difference.

上面的命令将使用diff-so-fancy来显示差异。

Image for post

If you want to make diff-so-fancy as default diff viewer, you can use

如果要将diff-so-fancy作为默认的diff查看器,可以使用

git config --global core.pager "diff-so-fancy | less --tabs=4 -RFX"

Now you can just use git diff to use diff-so-fancy.

现在,您可以使用git diff来使用diff-so-fancy。

Now for some reason, you may wish to use the default git diff to view the change even after setting diff-so-fancy.

现在由于某种原因,即使设置了diff-so-fancy之后,您仍可能希望使用默认的git diff查看更改。

In that case, you can use

在这种情况下,您可以使用

git --no-pager diff

The above command will bypass diff-so-fancy. So the default diff view will be used.

上面的命令将绕过diff-so-fancy。 因此,将使用默认的差异视图。

从默认选项中删除diff-so-fancy (Remove diff-so-fancy from the default option)

To remove diff-so-fancy from the default git diff, you can set the pager as

要从默认的git diff中删除diff-so-fancy,可以将分页器设置为

git config --global core.pager 'less'

Git uses a pager to display the content. Pager is used in commands like git-diff, git-log. By default, a pager called less is used by Git.

Git使用寻呼机显示内容。 Pager用于git-diff, git-log等命令 默认情况下,Git使用称为less的寻呼机。

So in the above command, I have set the default pager to Git.

因此,在上面的命令中,我将默认寻呼机设置为Git。

diff-so-fancy comes with few options. You can see that in the repo.

diff-so-fancy很少提供选择。 您可以在回购中看到它。

Thank you for reading, I hope you learned something new :)

谢谢您的阅读,希望您学到了一些新的东西:)

If you have come this much, then I think you are much interested in Git. You can subscribe to my newsletter GitBetter to get tricks, tips, and advanced topics of Git.

如果您来得这么多,那么我认为您对Git很有兴趣。 您可以订阅我的时事通讯 GitBetter 以获得Git的技巧,窍门和高级主题。

翻译自: https://levelup.gitconnected.com/how-to-customize-git-diff-to-spot-changes-faster-42acd0e8f515

git diff 修改

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值