简体   繁体   English

Git Windows 共享卷与 Unix docker 容器的行尾问题

[英]Git Line Endings problem on a Windows shared volume with a Unix docker container

I'm working on Windows and use centOS docker containers for my development.我正在开发 Windows 并使用 centOS docker 容器进行开发。 I also have a volume shared between my containers and a local folder.我还有一个在容器和本地文件夹之间共享的卷。

The problem is: when cloning a repository from windows into the shared volume or from the container into the shared volume, a git status does not return the same thing when it is executed in the container and on the local machine.问题是:将存储库从 windows 克隆到共享卷或从容器克隆到共享卷时, git status在容器和本地计算机上执行时不会返回相同的内容。 I expect it to be the same and tried different configurations without success:我希望它是相同的并尝试了不同的配置但没有成功:

  • git config --global core.autocrlf true/input/false on the local machine and in the container git config --global core.autocrlf true/input/false在本地机器和容器中
  • git config --global core.crlf true/false/auto on the local machine and in the container git config --global core.crlf true/false/auto在本地机器和容器中
  • git config --global core.eol lf ... git config --global core.eol lf ...

Does anyone have the right configuration of Git to get an identical git status from the container and on the local machine without modifying the.gitattributes?是否有人拥有 Git 的正确配置,可以在不修改 .git 属性的情况下从容器和本地机器上获得相同的git status

The way to configure line endings is:配置行尾的方法是:

On Linux:在 Linux 上:

git config --global core.autocrlf input

On Windows:在 Windows 上:

git config --global core.autocrlf true

You can also set repository-specific configurations:您还可以设置特定于存储库的配置:

cd /path/to/repo
git config core.autocrtlf <value>

In your situation, it sounds that if you set git config --global core.autocrlf input in your CentOS containers and git config --global core.autocrlf true for your Windows machine, you shouldn't have issues.在您的情况下,听起来如果您在 CentOS 容器中设置git config --global core.autocrlf input并为您的 Windows 机器设置git config --global core.autocrlf true ,则应该没有问题。

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

相关问题 我可以在命令行上用Windows行尾替换Unix行尾吗? - Can I replace Unix line endings with Windows line endings on the commandline? Windows服务器上的Unix风格的行尾 - Unix-style line endings on Windows servers Windows 命令转换 Unix 行尾? - Windows command to convert Unix line endings? Git - Windows和Linux的行结尾 - Git - Windows AND linux line-endings 如何配置Compass在Windows上使用Unix行结尾生成文件? - How to configure Compass to generate files with Unix line endings on Windows? 如何使用 Jenkins 以 Unix 行结尾检查 Windows 中的 CVS 存储库? - How to check out a CVS repository in Windows with Unix line endings with Jenkins? 使用 windows 上的 docker 卷(仅在 docker 容器内部)或与主机操作系统安装/共享卷时,读/写性能是否更好? - Is read/write performance better with docker volumes on windows (inside of a docker container only) or a mounted / shared volume with host OS? Docker容器内部如何访问共享卷 - inside Docker container how to access shared volume Git - 在 Linux 上使用 Linux 样式的行结尾,在 Windows 上使用 Windows 样式的行结尾 - Git - Use Linux-style Line Endings on Linux and Windows-style Line Endings on Windows Docker:在 Windows 主机上挂载卷 - Windows Container - Docker: Mount volume on Windows host - Windows Container
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM