[英]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.