简体   繁体   English

用回购中的gzip文件进行git pull?

[英]git pull with gzip files in repo?

I have a repo that contains my minified css/js files. 我有一个包含我的缩小的CSS / JS文件的存储库。 Some of them are gzipped. 其中一些被压缩。 When i go between staging and production doing push and pulls it tries to auto merge and fails on the gz ones citing it cannot auto merge binary files. 当我在暂存和生产之间执行推拉操作时,它尝试自动合并,并在gz上失败,理由是它无法自动合并二进制文件。

Is there a way to tell git to never try to merge a certain directory but rather only push that directories changes when a push request is made? 有没有办法告诉git不要尝试合并某个目录,而只在发出请求时才推送目录更改?

Any other ways you guys go about this? 你们还有其他方法吗?

Thanks!! 谢谢!!

UPDATE: 更新:

I tried putting the following in .gitattributes 我尝试将以下内容放在.gitattributes中

*.gz merge=keepTheir

And still getting this whenever I push: (mind you, someone else pushed before me and updated files into that repo) 每次我推送时仍会得到:(请注意,其他人在我之前推送并将文件更新到该存储库中)

Auto-merging public/assets/upload.css.gz
CONFLICT (content): Merge conflict in public/assets/upload.css.gz

What am I doing wrong? 我究竟做错了什么?

If you need the content you want to push to overwrite (instead of merge) the destination, you can define a custom merge driver in .gitattribute file in order to specify how you want the *.gz files to be merged. 如果需要要推送的内容以覆盖(而不是合并)目标,则可以在.gitattribute文件中定义自定义合并驱动程序,以指定希望如何合并*.gz文件。

See this answer as an example . 请参阅此答案作为示例

.gitattributes

*.gz merge=keepTheir

(based on " git command for making one branch like another ") (基于“ 用于使一个分支像另一个分支的git命令 ”)

Maybe you want to ignore the minified version because they are just a minified representation of the full files? 也许您想忽略缩小版本,因为它们只是完整文件的缩小表示?

Include the filenames in /.gitignore and commit a change adding this file. /.gitignore包含文件名,并提交更改以添加此文件。 Git will stop tracking changes to the minified de-facto-copies uselessly. Git将停止无用地跟踪对缩小的事实副本的更改。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM