标签: core.autocrlf

处理Cygwin Git和Git for Windows中的EOL字符访问同一个存储库

我的意思autocrlf是对的.在我的cygwin-shell中git status给出了我所有更改的正确列表.

在Git Bash中git status说我修改了项目中的所有文件.我也在Git GUI和IntelliJ中的Changes-tab中看到了这一点.

这怎么可能,更重要的是,我该如何解决?

git cygwin line-endings msysgit core.autocrlf

6
推荐指数
1
解决办法
2811
查看次数

在 Windows 中覆盖 .gitattributes text=auto

这是非常不直观的:

C:\python-tdl\examples\termbox>git config core.autocrlf
false

C:\python-tdl\examples\termbox>git commit termbox.py
warning: LF will be replaced by CRLF in examples/termbox/termbox.py.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in examples/termbox/termbox.py.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in examples/termbox/termbox.py.
The file will have its original line endings in your working directory.
Aborting commit due to empty commit message.
Run Code Online (Sandbox Code Playgroud)

根据各种媒体,core.autocrlf=false …

windows git gitattributes core.autocrlf

6
推荐指数
2
解决办法
4702
查看次数

行结尾:Git 合并创建重复项而不会发生冲突

Git 自动合并问题:

当在两个不同的分支文件中提交相同的代码时,其中一个分支代码在开始时具有额外的 CRLF/LF。合并时自动合并文件会创建重复项而不会产生任何冲突。请尽早告知。

下图显示了文本文件中所有可能的符号。注意:A 分支没有换行(行:245)。下面的自动合并会创建重复项而不会显示冲突。

描述自动合并问题的图片

git merge newline core.autocrlf

6
推荐指数
1
解决办法
2108
查看次数

强制所有行结尾都为 LF for git

我为 Windows 和 linux 开发。我的 Linux 开发环境是在我的 Windows 主机上运行的虚拟机。我共享了一些目录(实际上是在起诉 samba,而不是内置的虚拟机共享文件夹,所以该目录实际上是在 linux 来宾上并共享给主机)

我们正在从 svn 迁移到 git。我想在我的 Windows 机器上运行 Source Tree(Linux 是无头的)来进行版本控制。但我希望所有文件都有 linux 行尾(LF)。

我尝试按照git repo 和工作副本中的Force LF eol 中的说明进行操作,但它们对我不起作用。

我已将配置设置如下:

[adamc@adamc-centos scripts]$ git config core.autocrlf
input
[adamc@adamc-centos scripts]$ git config  core.eol
lf
Run Code Online (Sandbox Code Playgroud)

我的 .gitattributes 中有以下内容(甚至强制 .sh 成为文本文件并再次指定 eol)

* text=auto
*.sh    text eol=lf
Run Code Online (Sandbox Code Playgroud)

我已经运行了那里指定的 checkout-index 命令,但我仍然有带有 Windows 行结尾的 .sh 文件!

[adamc@adamc-centos scripts]$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, …
Run Code Online (Sandbox Code Playgroud)

git newline core.autocrlf

6
推荐指数
1
解决办法
5770
查看次数

Windows 开发和 linux 部署的 Git 行尾

在这一点上,我觉得我已经阅读了关于 core.autocrfl 的所有在线文章以及在 中指定行尾的各种方法.gitattributes,但我仍然无法真正弄清楚我需要什么。

我们整个团队在 Windows 上开发,我们的应用程序部署到 Linux。我想控制整个策略的使用,.gitattributes以便没有人担心更改他们的设置。我的.gitattributes文件的当前配置如下,从这个 git repo稍微修改

我们有一个 Java 项目并在 Eclipse 中开发,因此查看 LF 结尾的文件不是问题。目前,我并不乐观,但我想我们在存储库中有混合的结局。

我的目标是:

  1. 开发人员不必担心更改 Git 中的设置等。

  2. 由于在结帐时自动执行行结束更改,因此克隆存储库不应使其处于修改状态,从而要求开发人员提交他/她没有更改的文件

  3. 我们的 Jenkins 服务器在 Linux 上。当它克隆存储库时,它也不应该有一个修改的状态

我将.gitattributes文件更改为下面的文件并删除了索引,由于行尾,我现在有超过 3000 个文件待提交。如果我提交这个,我的问题会得到解决吗,我的上述要求会得到满足吗?

# Handle line endings automatically for files detected as text
# and leave all files detected as binary untouched.
* text=auto

#
# The above will handle all files NOT found below
#
# These files are text …
Run Code Online (Sandbox Code Playgroud)

java linux windows git core.autocrlf

6
推荐指数
0
解决办法
426
查看次数

VSCode 在文件保存时将 CRFL 更改为 LF,并且 git 记录更改,即使没有更改

我注意到 VSCode 中有一个奇怪的行为,当我保存文件时,即使我没有进行任何更改,我也可以在右下角看到它从 CRLF 更改为 LF。即使我做了一些更改,git 也会跟踪同时添加和删除的额外行。

我正在 Windows 上工作,到目前为止我没有遇到任何问题,它刚刚开始发生。我尝试将 VSCode 中 EOL 的全局设置设置为 CRLF,并将 Prettier 扩展也设置为 CRLF(因为我无法禁用它),但问题仍然存在。

我是新手,在网上找不到类似的问题,只是说明如何设置 CRLF。

git newline lf core.autocrlf visual-studio-code

6
推荐指数
1
解决办法
1万
查看次数

当我使用git将单个文件签出到其他位置时,如何保留行结尾?

我想将git存储库中的单个文件签出到不同的位置(除了工作目录)并保留当前正在工作的目录.我希望git以正确的行结尾检查我的文件.

我在Windows上工作,但我在Linux中也有同样的问题.

这是我的场景(Win7 64位):

首先,我确保git在提交时将CRLF转换为LF,在结帐时将LF转换为CRLF:

git config --local core.autocrlf true
Run Code Online (Sandbox Code Playgroud)

然后我创建一个名为crlf.txt的文件,其中包含CRLF行结尾并提交它:

git add crlf.txt
git commit -m "File with crlf"
Run Code Online (Sandbox Code Playgroud)

我在crlf.txt中更改了一些内容并提交它:

git add crlf.txt
git commit -m "Change in crlf.txt"
Run Code Online (Sandbox Code Playgroud)

现在我想得到像第一次提交时的crlf.txt:

git show HEAD~1:crlf.txt > "/home/user/crlf_like_in_head-1.txt"
Run Code Online (Sandbox Code Playgroud)

文件"crlf_like_in_head-1.txt"不包含CRLF而是LF.我认为git show是正确的,因为它显示了文件内容,就像它在存储库中一样(core.autocrlf = true将CRLF转换为LF).我知道从文档中我尝试使用core.autocrlf = false.使用core.autocrlf = false"crlf_like_in_head-1.txt"包含CRLF.我知道我可以轻松地将LF转换为CRLF,但我必须确保结果文件与使用git检出的结果文件相同.

我知道我也可以使用git checkout签出一个文件:

git checkout HEAD~1 crlf.txt
Run Code Online (Sandbox Code Playgroud)

但它覆盖了工作目录中crlf.txt的当前内容(如果crlf.txt处于脏状态),我也无法通过git checkout将其签出到另一个文件夹.

git git-checkout core.autocrlf git-show

5
推荐指数
1
解决办法
1165
查看次数

.gitattributes与core.autocrlf unset

我的存储库中有一个.gitattributes文件,看起来像这样

* text=auto
*.txt text
Run Code Online (Sandbox Code Playgroud)

我在存储库,全局和系统设置中取消了core.autocrlf的设置.根据gitattributes的文档,我的理解是存储库中名称以.txt结尾的所有文件都应该使用本机行结尾进行检出.但我所看到的是,即使在Windows上,.txt文件也总是有LF用于行结尾.鉴于此配置,为什么Windows上的行结尾CRLF不是?

git gitattributes core.autocrlf

5
推荐指数
1
解决办法
6052
查看次数

使用 git config --global core.autocrlf false 是否有任何风险或缺点

我使用Windows和 PHPStorm IDE 进行 Web 开发。在 Git Bash 中,当我想添加 ( git add .) 或commit- 时,会出现数百个这样的警告:

warning: LF will be replaced by CRLF in ...
The file will have its original line endings in your working directory.
Run Code Online (Sandbox Code Playgroud)

但是如果我在 Git Bash 中执行以下操作:

git config --global core.autocrlf false
Run Code Online (Sandbox Code Playgroud)

不再有这些警告。core.autocrlf设置为有任何风险或缺点false吗?或者我不应该担心?正如我已经写过的,我正在使用 Web 应用程序(php 文件、html 文件、css...稍后将被推送到 GitHub 上的某个远程代表或复制到生产 Linux 服务器...)。对不起,我的英语不好。

git bash github core.autocrlf phpstorm

5
推荐指数
1
解决办法
551
查看次数

/usr/bin/env: 'bash\r': 没有那个文件或目录

在 win10 的 Linux 终端中设置 docker 后我遇到了问题。当我尝试构建时,它显示以下错误。

/usr/bin/env: ‘bash\r’: No such file or directory
ERROR: Service 'magento2' failed to build: The command '/bin/sh -c /opt/docker/bin/service.d/autosync.sh install     && docker-service-enable autosync' returned a non-zero code: 127
Run Code Online (Sandbox Code Playgroud)

它是 git line 结束错误,我该如何解决?

git newline core.autocrlf docker windows-subsystem-for-linux

5
推荐指数
2
解决办法
2万
查看次数