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

标签 javascript node.js git git-merge

我有这个命令

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/

相关文章:

node.js - 如何在 Electron 应用程序中本地启动 Node 服务器

javascript - 在网站上创建购物 list 选项,供您在其中写入购物 list

javascript - TinyMCE v4 将自定义项目添加到上下文菜单

javascript - 如何确保在循环完成后执行语句?

git - 重置 --soft 和 --mixed 之间的区别

git - 删除/切断 Git 的修订/提交历史

eclipse - 使用多个 Git 帐户

javascript - 当数据可用时,Material UI 组件不会自动完成

javascript - 异步 modernizr 可以吗?

javascript - 如何使用自定义的快速验证器?