在与使用不同操作系统的人一起工作时,由于行结束,我遇到了合并冲突问题。我在 Windows 上工作,我的同事在 Mac 上工作。当他推送他的更改时,有时他没有处理过的文件会在 diff 中显示为已更改,因为现在^M
每个文件上都会显示行尾。这导致了合并冲突。我在 Git 文档中阅读了以下内容:
当您将文件添加到索引时,Git 可以通过将 CRLF 行结尾自动转换为 LF 来处理此问题,反之亦然,当它检出代码到您的文件系统时。您可以使用 core.autocrlf 设置打开此功能。如果您使用的是 Windows 计算机,请将其设置为 true?—?这会在您检出代码时将 LF 结尾转换为 CRLF:
$ git config --global core.autocrlf true 如果你在使用 LF 行尾的 Linux 或 macOS 系统上,那么你不希望 Git 在检出文件时自动转换它们;但是,如果意外引入了带有 CRLF 结尾的文件,那么您可能需要 Git 修复它。您可以通过将 core.autocrlf 设置为输入来告诉 Git 在提交时将 CRLF 转换为 LF,而不是相反:
$ git config --global core.autocrlf input 这个设置应该让你在 Windows 结账中使用 CRLF 结尾,但在 macOS 和 Linux 系统以及存储库中使用 LF 结尾。
这是有道理的,但我仍然不清楚这些文件是如何在 repo 中实际提交的。例如,如果他在他的系统上创建一个文件,它会有所有的LF
行结尾,对吗?因此,当他提交时,我认为这些行结尾保持原样。据我所知,当我拉动时,我的autocrlf
存在true
会用CRLF
行尾检查它们。(我收到警告warning: …
刚刚克隆了这个,目录立即有变化吗?
我从来没有遇到过这样的事情,我很好奇为什么会这样?以及这怎么可能呢?
更新:
我在使用git clone git://github.com/horndude77/open-scores.git
git状态后立即克隆了repo 并显示:
git status
# Not currently on any branch.
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: SaintSaensRomanceOp36/defs.ily
# modified: SaintSaensRomanceOp36/horn.ily
#
no changes added to commit (use "git add" and/or "git commit -a")
Run Code Online (Sandbox Code Playgroud)
git diff揭示:
warning: CRLF will be replaced by LF in SaintSaensRomanceOp36/defs.ily.
The …
Run Code Online (Sandbox Code Playgroud) 一个同事在更改了项目文件的权限后进行了git提交(他不希望提交它们).
现在我们所有的图像都"被破坏"不可读,但我们不知道如何以及如何做.
以下是git show edd703783a8802284fb975e9f354394541f1bad5
显示的内容:
diff --git a/public/bootstrap/img/glyphicons-halflings-white.png b/public/bootstrap/img/glyphicons-halflings-white.png
index 3bf6484..c016d6b 100644
Binary files a/public/bootstrap/img/glyphicons-halflings-white.png and b/public/bootstrap/img/glyphicons-halflings-white.png differ
Run Code Online (Sandbox Code Playgroud)
这是什么意思?
我们尝试删除并重新提交图像,但问题仍然存在.一旦我们在分支上切换/重新切换,图像就会被破坏.
我甚至尝试git revert
了提交,但它将所有图像文件置于更新状态并因以下错误而停止:
error: 'commit' is not possible because you have unmerged files.
hint: Fix them up in the work tree,
hint: and then use 'git add/rm <file>' as
hint: appropriate to mark resolution and make a commit,
hint: or use 'git commit -a'.
fatal: Exiting because of an unresolved conflict.
Run Code Online (Sandbox Code Playgroud)
现在我无法恢复它,并且提交已经在几天前推送(并部署到开发环境),所以我不能改变或类似的东西.
我正在从一个存储库中签出,在那里我是 Mac 和 Linux 海洋中唯一的 Windows 用户。我的 IDE 在我的 Windows 机器上运行,代码被推送到 VM。代码不会同步回主机。当我准备在我的 Windows 主机上添加/提交时,我收到warning: LF will be replaced by CRLF
消息。
这些是我的 Git 设置:
core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
diff.astextplain.textconv=astextplain
rebase.autosquash=true
credential.helper=manager
core.editor='C:/Program Files/Notepad++/notepad++.exe' -multiInst -nosession
core.filemode=false
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
Run Code Online (Sandbox Code Playgroud)
我不确定为什么core.filemode=false
会列出两次。
我在 Windows 上收到此警告有什么原因吗?我是否在我的设置中做一些愚蠢的事情(完全可能)?或者,这在这种情况下是否有意义,如果是,为什么?
当我使用将文件添加到暂存区域时,为什么显示警告git add -A
并出现以下消息:
这是什么意思 ?