使用git自动将文件内容转换为适合所有平台的格式

huangapple go评论71阅读模式
英文:

Using git to auto-convert files contents to fit all platform

问题

我有一个多平台的项目,不时会出现一些通用数据文件,这些文件针对一种体系结构格式化,但会导致另一种体系结构的编译失败。

例如,一个被多个平台(macOS/Windows)使用的 XML 文件,换行符只格式化为单一体系结构(例如:\r\n)。

问题是我是否可以让 Git 处理这个问题,根据体系结构的不同,显示每个文件的正确格式?

谢谢!

英文:

I've got multi platform based project, and from time to time, Some common data files that are formatted for one architecture, breaks compilation on the other arch.

For example, an XML file used by multiple platforms (macOS/Windows) and have newline formatted for single arch only (for example : \r\n)

The question is whether I can let git handle this and show each file in the correct formatting according to the architecture ?

Thanks !

答案1

得分: 2

这个问题不特定于macOS。实际上,这是一个Windows与Unix(包括Linux和macOS)之间的问题。如果你搜索git newline conversion,你会找到很多相关的文档,比如https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings。更不用说在Stackoverflow上已经有人提出类似问题,比如https://stackoverflow.com/questions/10418975/how-to-change-line-ending-settings。

英文:

This question isn't specific to macOS. It's really a Windows versus Unix (which includes Linux and macOS) issue. If you google for git newline conversion you'll find many relevant documents such as https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings. Not to mention other times this has been asked on Stackoverflow such as https://stackoverflow.com/questions/10418975/how-to-change-line-ending-settings.

huangapple
  • 本文由 发表于 2023年7月3日 15:26:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/76602661.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定