跨平台git配置的最佳实践? [英] Best practices for cross platform git config?

查看:206
本文介绍了跨平台git配置的最佳实践?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Context



我的许多应用程序用户配置文件保存在git存储库中,以便在多台机器和多个平台间轻松共享。这些配置文件中包含 .gitconfig ,其中包含以下用于处理回车换行字符的设置

  [core] 
autocrlf = true
safecrlf = false



< h2>问题

这些设置也适用于导致模糊错误的GNU / Linux平台。

问题



处理配置文件中这些平台特定差异的一些最佳实践是什么?

建议的解决方案



我意识到这个问题可以通过为每个平台建立一个分支并保持共同性来解决当主站点向前移动时,主站中的东西与平台分支合并。我想知道这个问题是否有解决方案?

解决方案

我已经回顾了类型的配置设置( crlf )在问题中进行了广泛的讨论:

使用代码分发git配置



结论是:



 
* .java + crlf
* .txt + crlf
...




  • 避免进行任何形式的转换的文件不需要它,因为这种转换的各种副作用在合并时, git status ,shell环境和 svn import (参见为代码分发git配置链接和引用)。

  • 避免任何 crlf 转换,如果可以的话。






现在,关于每个平台设置的具体问题,分支并不总是正确的工具,尤其是对于与非程序相关的数据(即;这些设置与您正在开发的内容无关,只针对存储开发历史的VCS)。 正如问题中所述 Git:如何维护一个项目的两个分支和合并只有共享数据?


如果将系统相关代码放在不同的目录中并处理,您的生活将会变得非常简单在构建系统中使用跨平台的依赖关系(Makefile或任何你使用的)。

在这种情况下,虽然可以使用分支对于依赖于系统的代码,我会建议使用支持工具系统相关设置的目录,使用脚本能够构建适当的 .gitattributes 文件以根据回购部署平台。


Context

A number of my application user configuration files are kept in a git repository for easy sharing across multiple machines and multiple platforms. Amongst these configuration files is .gitconfig which contains the following settings for handling the carriage return linefeed characters

[core]
    autocrlf = true
    safecrlf = false

Problem

These settings also gets applied on a GNU/Linux platform which causes obscure errors.

Question

What are some best practices for handling these platform specific differences in configuration files?

Proposed solution

I realize this problem could be solved by having a branch for each platform and keeping the common stuff in master and merging with the platform branch when master moves forward. I'm wondering if there are any easier solutions to this problem?

解决方案

I have reviewed that kind of config setting (crlf) extensively in the question:
distributing git configuration with the code.

The conclusion was:

*.java +crlf
*.txt +crlf
...

  • avoid doing any kind of conversion of type of files which don't need it, because of the various side-effect of such a conversion on merges, git status, shell environment and svn import (see "distributing git configuration with the code" for links and references).
  • avoid any crlf conversion altogether if you can.

Now, regarding the specific issue of per-platform settings, branch is not always the right tool, especially for non-program related data (i.e; those settings are not related to what you are developing, only to the VCS storing the history of your development)

As stated in the question Git: How to maintain two branches of a project and merge only shared data?:

your life will be vastly simpler if you put the system-dependent code in different directories and deal with the cross-platform dependencies in the build system (Makefiles or whatever you use).

In this case, while branches could be use for system-dependent code, I would recommend directory for support tools system-dependent settings, with a script able to build the appropriate .gitattributes file to apply the right setting depending on the repo deployment platform.

这篇关于跨平台git配置的最佳实践?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆