使用 SVN Diff 时 Ubuntu Linux 上的 WinSCP 行尾样式问题

发布于 2024-08-16 07:56:40 字数 241 浏览 14 评论 0原文

我的文件位于远程 Ubuntu Linux 服务器上。当我下载文件并在 WinSCP 文本编辑器或 Notepad++ 中编辑它时,文件行尾样式更改为 Windows。因此,当我将文件重新保存回 Ubuntu 时,这些行已关闭,并且 SVN Diff 认为每一行都已更改。

仅供参考,我通过双击 WinSCP 中的文件来编辑该文件。该程序在编辑器中启动该文件。每次保存时,文件都会自动复制回 Linux 服务器。

如何防止行尾样式问题?

My files are on a remote Ubuntu Linux server. When I download the files and edit it in either the WinSCP text editor or Notepad++, the file end-of-line style changes to Windows. So when I resave the file back to Ubuntu the lines are off and SVN Diff thinks every line has changed.

FYI, I edit the file by double clicking the file in WinSCP. This program launches the file in the editor. Every time I save, the file is automatically copied back to the Linux server.

How do I prevent the end-of-line style issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

╰つ倒转 2024-08-23 07:56:40

此帖子有帮助吗?更准确地说这部分:

由此看来,您似乎强制 WinSCP 使用文本模式传输,这意味着 unix->dos 转换。只需强制二进制模式即可避免转换。

Does this thread help? More precisely this part:

From this, it seems to me that you have forced WinSCP to use text mode transfer, which imply the unix->dos conversion. Just force the binary mode to avoid the conversion.

帝王念 2024-08-23 07:56:40

我无法弄清楚为什么会出现空格问题,但我能够弄清楚如何忽略空格。

您可以使用:

svn diff -x'-uw --ignore-eol-style'

这已经足够好了。

I wasn't able to figure out why I had the whitespace issue but I was able to figure out how to ignore whitespaces.

You can use:

svn diff -x'-uw --ignore-eol-style'

This worked well enough.

微凉 2024-08-23 07:56:40

可以通过在 WinSCP 中进入外部编辑器的配置来简单而适当地修复该问题

View >首选项>编辑器

选择您的外部编辑器,然后单击编辑...

然后取消选中:在外部编辑器中编辑的文件强制使用文本传输模式

The simple and appropriate fix to that issue can be done by going into the configuration of your external editor in WinSCP

In: View > Preferences > Editors

Select your external editor and click Edit ...

Then, uncheck: Force text transfer mode for files edited in external editor

掩于岁月 2024-08-23 07:56:40

您需要使用 unix 行格式。要进行设置,请转到“设置”>“首选项”并选择“新文档/默认目录”选项卡。在“新建文档”控件中找到“格式”并选择“Unix”。这将确保任何新文档都具有正确的格式。我已经在远程 Linux 服务器上使用过它,但没有发现问题。

通常,将使用临时名称创建返回的文件并将更改写入其中。然后,原始文件将被删除,新文件将被重命名以取代其位置。这将使返回的文件成为“新”文档,因此此首选项设置应提供正确的格式。

You need to use the unix line format. To set this, go to Settings>Preferences and select the "New Documents/Default Directory" tab. Find "Format" in the "New Document" controls and select "Unix". This will ensure any new document has the correct format. I have used this with a remote linux server and have not seen a problem.

Typically, the returned file would be created with a temporary name and the changes written to it. The original file would then be removed and the new file renamed to take its place. This would make the returned file a "new" document so this preference setting should give the correct format.

许你一世情深 2024-08-23 07:56:40

我在Windows上使用Notepand2和WinSCP编辑文件,服务器在Linux上。

就我而言,问题出在 WinSCP 连接本身。

我在连接之前单击“编辑”,然后单击“高级”,有行尾字符的选项。改变它解决了我的问题。

屏幕上的选项已经是有效的选项。以前只有“LF”。

在此处输入图像描述

I use Notepand2 and WinSCP to edit files on Windows and server is on Linux.

In my case the problem was with WinSCP connection itself.

I clicked "Edit" before the connection and then "Advanced" there was option for End-of-line characters. Changing it solved the problem in my case.

Option on the screen is already the one that worked. Ealier there was "LF" only.

enter image description here

我乃一代侩神 2024-08-23 07:56:40

如果您使用 WinSCP 进行文本/ascii 模式传输,它会在上传时将行尾样式转换回 Unix。

所以我猜问题可能是你的文件最初实际上具有 Windows 行尾样式。下载时,没有任何变化,但上传时,它会转换为 Unix 风格。

要么修复你的文件以使用它应该的 Unix 风格(如果是这种情况),要么使用二进制传输模式。

您不仅需要一般配置 WinSCP 的二进制传输模式(WinSCP 最新版本中的默认设置),而且还需要确保首选项选项对在外部编辑器中编辑的文件强制使用文本传输模式 您的外部编辑器 (Notepad++) 已关闭:
https://winscp.net/eng/docs/ui_editor_preferences

请注意,此选项不可用用于 WinSCP 内部编辑器。使用它,文件始终以文本/ascii 模式传输。

If you use text/ascii mode transfer with WinSCP, it would convert the end-of-line style back to Unix on upload.

So I guess the problem might be that your file actually has Windows end-of-line style initially. On download, nothing changes, but on upload, it gets converted to Unix style.

Either fix your file to use the Unix style as it should (if that's the case) or use the binary transfer mode.

Not only you need to configure the binary transfer mode for WinSCP in general (what is the default in recent versions of WinSCP), but you also need to make sure that the preference option Force text transfer mode for files edited in external editor for your external editor (Notepad++) is off:
https://winscp.net/eng/docs/ui_editor_preferences

Note that this option is not available for WinSCP internal editor. With it files are always transferred in the text/ascii mode.

但可醉心 2024-08-23 07:56:40

这是对 Djidiouf 答案的补充。

  1. 转到WinSCP(ver.5.17.9)选项->首选项->编辑器
    取消选中对在外部编辑器中编辑的文件强制测试传输模式
    取消选中强制测试在外部编辑器中编辑的文件的传输模式

  2. 转到会话->高级->环境->行尾字符
    选择LF
    LF 应该被选中

  3. 尝试从服务器提取文件,验证其 EOL 风格
    notepad++

This a supplement to Djidiouf's answer.

  1. Go to WinSCP(ver.5.17.9) Options->Preferences->Editors
    Uncheck Force test transfer mode for files edited in external editor
    Uncheck Force test transfer mode for files edited in external editor

  2. Go to Session->Advanced->Environment->End-of-line characters
    Select LF
    LF should be selected

  3. Trying to pull a file from server, verifying its EOL-sytle
    notepad++

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文