简体   繁体   English

`git commit -p`:每个字符我可以得到更好的差异吗?

[英]`git commit -p`: can I get better diff, per chars?

In such cases: 在这种情况下: git commit -p it is difficult to say - here was changed the indentation only or maybe also my cat updated a few chars. 很难说-这里只是更改了缩进,或者也许我的猫也更新了一些字符。 I know that exists for example diff-so-fancy where I can see the difference on the chars level, but there is no official out of the box solution? 我知道存在diff-so-fancy这样的地方,在这里我可以看到chars级别的区别,但是没有官方的开箱即用解决方案吗?

You can use git diff directly. 您可以直接使用git diff It does have options for whitespace handling. 它确实具有空白处理选项。 -> man git-diff -> man git-diff

You are looking for the --word-diff option. 您正在寻找--word-diff选项。

For the file 对于文件

The quick brown fox jumps over the lazy dog

changed to 变成

    The quick brown fox jumps over the sleepy dog

git diff --word-diff shows git diff --word-diff显示

   The quick brown fox jumps over the [-lazy-]{+sleepy+} dog

EDIT: Oh, I realized that your problem is the very long URL that is treated as a single word. 编辑:哦,我意识到您的问题是被视为一个单词的非常长的URL。 --word-diff-regex may help here. --word-diff-regex在这里可能会有所帮助。

I tried a different, but similar URL with git diff --word-diff-regex="/|[^[:space:]]" , which worked quite well. 我用git diff --word-diff-regex="/|[^[:space:]]"尝试了一个不同但相似的URL,效果很好。 You might however want to improve that regex. 但是,您可能需要改进该正则表达式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在没有git commit的情况下,如何在git add和git checkout之后找回我的差异? - How can I get my diff back after git add and git checkout without git commit? 我怎样才能在 git 中获取文件的每次提交的代码行 - How can i get the line of code per commit for a file in git 我可以让git add -p显示更改,例如git diff --word-diff吗? - Can I make git add -p show changes like git diff --word-diff? 如何获取git log来限制每条提交消息的行数? - How can I get git log to limit the number of lines per commit message? 如何获得第一次提交的 Git 差异? - How to get Git diff of the first commit? Git秀 <commit> 并获取文件子集的差异 - Git show <commit> and get diff for a file subset 我如何从git压缩的提交中获取最后的提交 - How can i get the last commit from squashed commit in git 如何通过`git diff`获得`git commit --verbose`输出? - How to get `git commit --verbose` output via `git diff`? 如何在Git中压缩提交,以便可以将我的上一次提交与结帐进行比较,而看不到临时提交? - How can I squash a commit in Git so that I can diff my last commit against the checkout without seeing the interim commits? 检查git diff后,如何忽略一些我不想添加到此提交中的文件中的更改? - After checking git diff, how can I ignore changes in a few files that I dont want to add to this commit?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM