git sourcetree 行结束问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25724969/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
sourcetree line ending issue
提问by user1683285
I am getting a very strange whitespace issue.
我遇到了一个非常奇怪的空白问题。
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.
我正在使用 wp-content/themes 文件夹中带有 .git repo 的 WordPress 站点的本地副本,以便跟踪对任何主题的所有更改等。
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'.
当我设置 repo 时,它认为每个文件(除了 gitignore 中的文件)都是新文件,我将它们作为“初始提交”提交。
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.
当我转储这些文件时,我在许多文件的第一个字符后插入了一些空格。
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 我也试过了
autocrlf = true
eol = native
In my local git config. .gitattributes is set to :
在我的本地 git 配置中。.gitattributes 设置为:
* text=auto
as advised by Force LF eol in git repo and working copy
按照git repo 和工作副本中的 Force LF eol 的建议
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.
到目前为止没有任何帮助。我在 Windows 机器上工作,但文件是从 linux 服务器上压缩的,只是解压缩到目录中。
回答by 8749236
Goto terminal and enter:
转到终端并输入:
git config --global core.autocrlf false
Then try to stage again.
然后再次尝试登台。
I susepct it is the same issue as this one
我怀疑它和这个问题是一样的
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.
由 git 尝试在您签出文件时自动将行尾样式转换为 CRLF 并在发送之前返回 LF 引起。
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.
您可以安全地禁用它并自行处理行尾问题或自行转换相关文件的行尾样式,但后者只会隐藏问题。
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.
此外,您将始终必须为每个新存储库进行初始提交,因为新存储库(git init
例如,不是克隆的,而是使用创建的)不包含任何文件,因此您必须指定要跟踪的文件初始提交。
For the space after first character issue, try to fix them manually and see if the problem reappears.
对于第一个字符问题后的空格,尝试手动修复它们,看看问题是否再次出现。