gpt4 book ai didi

javascript - merge 时仅忽略某些文件扩展名的空格

转载 作者:IT老高 更新时间:2023-10-28 23:16:32 26 4
gpt4 key购买 nike

我有这个命令

git merge -Xignore-all-space origin/dev

让我有点害怕 b/c 我害怕 merge 一个空格很重要的文件。有没有办法将它限制在某些文件中,像这样:

git merge -Xignore-all-space *.js origin/dev

最佳答案

任何时候你想为每个文件扩展名设置一个配置,一个好的起点是 gitattributes .
.gitattributes文件,您可以为每个文件或每个文件扩展名设置一个指令。

但是,*.js -whitespace I mentioned in 2009在 merge 期间可能不适用。

自从 ignore-all-space首先是 git diff option ,您可能需要设置 diff driver.gitattributes (同样,仅适用于 *.js 文件),模拟 --word-diff-regex

Use <regex> to decide what a word is, instead of considering runs of non-whitespace to be a word

Every non-overlapping match of the is considered a word. Anything between these matches is considered whitespace and ignored(!) for the purposes of finding differences.

You may want to append |[^[:space:]] to your regular expression to make sure that it matches all non-whitespace characters. A match that contains a newline is silently truncated(!) at the newline.

例如(进行调整以匹配您在 javascript 文件中对不带空格的差异所需的内容)

*.js    diff=js
[diff "js"]
wordRegex = "[^[:space:]]+"

关于javascript - merge 时仅忽略某些文件扩展名的空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49143341/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com