我需要从 merge 错误中排除 dist/
文件夹,我不在乎它是 他们的
、我们的
还是其他策略但我需要将它保留在修订控制中,因为这是部署到 Heroku 的方式。 .gitattributes
脚本似乎是要走的路。但我似乎无法完成这项工作。
我读了这个canonical answer还有这个similiar answer但无法找出我做错了什么。
我的.gitattributes
配置:
* text=auto
dist/ merge=keepMine
我的 .git/config
的相关部分:
[merge "keepMine"]
name = always keep mine dist during merge
driver = keepMine.sh %O %A %B
和keepMine.sh
(在我的项目根文件夹中,没有文件夹不在路径中,但是复制到路径中的文件夹没有帮助,也不是一个好的解决方案因为脚本应该是修订控制的一部分,所以所有开发人员都会得到它):
# copied as is from the SO answer
# I want to keep MY version when there is a conflict
# Nothing to do: %A (the second parameter) already contains my version
# Just indicate the merge has been successfully "resolved" with the exit status
exit 0
编辑: 还尝试了 git config merge.keepMine.driver true
,如上面的 SO 答案之一所建议的那样。没用。
但我仍然遇到 merge 错误(如果我创建它们),例如在 dist/styles/sdkasl.main.css
中。
我做错了什么?感谢您的帮助。
最佳答案
documentation在这方面不是很好。
You can also use Git attributes to tell Git to use different merge strategies for specific files in your project.
听起来不错!我们可以阅读 merge 策略 here并且有一个叫做我们的的,它真的很有帮助。
不幸的是,下一行粉碎了这个梦想。强调我的。
One very useful option is to tell Git to not try to merge specific files when they have conflicts, but rather to use your side of the merge over someone else’s.
对我们来说很遗憾,如果对 dist/
的更改在 feature
不要与master
冲突然后它们将 merge 到 dist/
中在 master
.第二个answer到 question你在上面链接讨论了这个。
我建议 post merge hook重置dist/
到一些原始状态。
关于Git:在 gitattribute 中为整个文件夹指定 git merge 策略 "ours"(或者只是禁用特定文件夹的 merge 错误?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21309276/