sourcetree行结束问题 [英] sourcetree line ending issue

查看:96
本文介绍了sourcetree行结束问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个非常奇怪的空白问题.

I am getting a very strange whitespace issue.

我正在使用wp-content/themes文件夹中带有.git repo的WordPress网站的本地副本,因此可以跟踪对任何主题的所有更改等.

I am working with a local copy of a WordPress site with the .git repo in the wp-content/themes folder so all changes to any theme are tracked etc.

设置回购协议时,它会将每个文件(除了gitignore中的文件除外)都视为新文件,并将它们提交为初始提交".

When I set up the repo it considered every file (apart from those in gitignore) as new files and I committed those as the 'initial commit'.

首先那很正常吗?要在设置新存储库时提交所有文件?第二-这是奇怪的行为.

Firstly is that normal? To have to commit all the files when setting up a new repo? 2nd - and this is the strange behaviour.

当我暂存这些文件时,我在许多文件的第一个字符之后插入了一些空格.

when I go to stage these files I get some whitespace inserted after the first character on many of the files.

我认为这与行尾有关.我将全局配置设置为autocrlf = true,也尝试过

I am thinkng this si something to do with line endings. I have my global config set to autocrlf = true also I have tried

 autocrlf = true
 eol = native

在我的本地git配置中..gitattributes设置为:

In my local git config. .gitattributes is set to :

* text=auto

根据的建议,在git repo中强制LF eol并正常工作复制

到目前为止,没有任何帮助.我正在Windows机器上工作,但是文件已从linux服务器上解压缩,然后才解压缩到目录中.

Nothing is helping so far. I am working on a windows machine, but the files were tarred from a linux server and just untarred into the directory.

推荐答案

转到终端并输入:

git config --global core.autocrlf false

然后尝试重新上演.

我怀疑这与由git引起的尝试在签出文件时自动将行尾样式转换为CRLF,并在发送文件之前将其转换回LF.

Caused by git attempts to automatically converts your line ending style to CRLF when you checkout a file and back to LF before sending it.

您可以安全地禁用它并自己处理行尾问题,也可以自己转换相关文件的行尾样式,但后者只能隐藏问题.

You can safely disable it and take care of line ending problems yourself or convert line ending style for the file in question by yourself but latter only hide the problem.

此外,您将始终必须为每个新存储库进行一次初始提交,因为新存储库(不是克隆的,而是使用 git init 创建的)不包含任何文件,因此您将必须通过进行初次提交来指定要跟踪的文件.

Also, you will always have to have an initial commit for each new repo, since new repo (not cloned but created with git init, for example) does not contain any file, therefore you will have to specify which files you would like to track by making an initial commit.

对于第一个字符后的空格,请尝试手动修复它们,然后查看问题是否再次出现.

For the space after first character issue, try to fix them manually and see if the problem reappears.

这篇关于sourcetree行结束问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆