简体   繁体   English

在 Windows 上下载 GitHub repo 作为 zip,包括 CRLF

[英]Download GitHub repo as zip on Windows, including CRLF

Because I use core.autocrlf on Windows, my linefeeds that I commit and push to GitHub get normalised from CRLF -> LF which is good.因为我在core.autocrlf ,所以我提交并推送到 GitHub 的换行符从CRLF -> LF标准化,这很好。 When I clone on Windows they get converted back LF -> CRLF .当我在 Windows 上克隆时,它们会转换回LF -> CRLF However I want to download my repo as zip on a Windows machine without git installed.但是我想在没有安装 git 的 Windows 机器上将我的 repo 下载为 zip。 Now the linefeeds are incorrect for Windows.现在 Windows 的换行符不正确。

Is there a way to download files from GitHub without git installed but still adding the CRLF back to the files?有没有办法在没有安装 git 的情况下从 GitHub 下载文件,但仍然将 CRLF 添加回文件?

When you download an archive from GitHub, it's essentially generated with git archive .当您从 GitHub 下载存档时,它实际上是使用git archive生成的。 That means what you get in the archive is what's in the repository, which means that Git doesn't perform CRLF translation.这意味着您在存档中得到的就是存储库中的内容,这意味着 Git 不执行 CRLF 转换。 GitHub doesn't provide an option to adjust this because Git doesn't provide such an option. GitHub 不提供调整此选项的选项,因为 Git 不提供此类选项。

What you're doing using LF in the repository and CRLF in the working tree (if you want that) is the right way to work with Git, and you should keep doing that.您在存储库中使用 LF 并在工作树中使用 CRLF(如果需要的话)是使用 Git 的正确方法,您应该继续这样做。

If you want to do a release with a zip file that contains files with line endings different than what's in the repo or with additional files that aren't included in the repo, then create a release on GitHub and upload such an archive as a release asset.如果您想使用 zip 文件发布一个版本,该文件包含行尾与回购中的文件不同的文件或回购中未包含的其他文件,则在 GitHub 上创建一个版本并上传此类存档作为版本资产。 Then you can include whatever line endings you want or whatever else you want in the archive and have it available without the repository.然后,您可以在存档中包含您想要的任何行尾或任何其他内容,并在没有存储库的情况下使用它。 Many common projects do exactly this.许多常见的项目正是这样做的。

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

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