本文介绍了git svn windows linux whitespace问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在linux上使用git(使用git-svn),同事在windows上使用svn。

很多时候,git报告空白问题。事实上,由于这些问题而无法提交线性历史记录,并且会产生合并冲突。

在Windows上配置svn / git和git-svn最简单的方法是什么?现在有空白的问题?



以下是报告的合并冲突,在master的线性历史记录中:

  error:patch failed:frontend / templates / frontend / base.html:38 
error:frontend / templates / frontend / base.html:patch does not apply
错误:补丁失败:frontend / templates / frontend / footer.html:1
错误:前端/ templates / frontend / footer.html:补丁不适用
错误:补丁失败:frontend / templates /frontend/index.html:1
错误:前端/模板/前端/ index.html:修补程序不适用
使用索引信息重建基础树...
;:15:尾随空格。

:20:尾随空格。
< a href ={%url frontend_index%}>
:22:尾随空格。
< / a>
:24:尾随空格。
< span class =companyname>
:25:尾随空格。
< a href ={%url frontend_index%}>
警告:压制74空格错误
警告:79行添加空格错误。
回落至修补基地和3路合并...
自动合并前/模板/前端/ base.html文件
冲突(含量):合并冲突前端/模板/前端/base.html
自动合并前端/ templates / frontend / index.html
CONFLICT(内容):在前端合并冲突/ templates / frontend / index.html
合并失败变化。
补丁失败时,0001模板更改

当您解决此问题时,请运行git rebase --continue。
如果您希望跳过此修补程序,请运行git rebase --skip。
要恢复原始分支并停止重新分配运行git rebase --abort。

如何解决空白问题?

解决方案


此添加到的.gitconfig

  [core] 
whitespace = nowarn

git rebase现在可以使用。 (你可以选择添加一些修复,-indent-with-non-tab,trailing-space 来让git在每次提交时修复所有的空格。好主意取决于你的项目规则和团队。)



解决eol错误

  [core] 
autocrlf = true

in你的 .gitconfig 。这将强制每个文本文件具有窗口行结束符。默认情况下, svn 会忽略行结束符,并且如果窗口上的文本编辑器是正常的,则可以使用这种方式。否则,将到你的svn配置(可选改变本地 CRLF )确保CRLF行结束一致。
$ b 设置 autocrlf = input 并将 native 更改为 LF ,以便贯穿始终如一的Linux行尾。


I use git (with git-svn) on linux and a colleague uses svn on windows.

So many times, git reports whitespace issues. In fact it fails to commit a linear history because of these problems and creates merge conflicts.

What is the simplest way to configure svn/git and git-svn on windows and linux so that there are now whitespace issues?

Following is a reported merge conflict, in a linear history on master:

error: patch failed: frontend/templates/frontend/base.html:38
error: frontend/templates/frontend/base.html: patch does not apply
error: patch failed: frontend/templates/frontend/footer.html:1
error: frontend/templates/frontend/footer.html: patch does not apply
error: patch failed: frontend/templates/frontend/index.html:1
error: frontend/templates/frontend/index.html: patch does not apply
Using index info to reconstruct a base tree...
<stdin>:15: trailing whitespace.

<stdin>:20: trailing whitespace.
          <a href="{% url frontend_index %}">
<stdin>:22: trailing whitespace.
          </a>
<stdin>:24: trailing whitespace.
        <span class="companyname">
<stdin>:25: trailing whitespace.
          <a href="{% url frontend_index %}">
warning: squelched 74 whitespace errors
warning: 79 lines add whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging frontend/templates/frontend/base.html
CONFLICT (content): Merge conflict in frontend/templates/frontend/base.html
Auto-merging frontend/templates/frontend/index.html
CONFLICT (content): Merge conflict in frontend/templates/frontend/index.html
Failed to merge in the changes.
Patch failed at 0001 template changes

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".

How do I solve the whitespace issues?

解决方案

Fixing whitespace errors

Add this to .gitconfig

[core]
  whitespace=nowarn

git rebase should now work. (You can optionally add some of fix,-indent-with-non-tab,trailing-space to that to have git fix all whitespaces at every commit. Whether that is a good idea depends on your project rules and team. )

Fixing eol errors

[core]
  autocrlf = true

in your .gitconfig. This will force every text file to have windows line endings. svn by default ignores line endings and if your text editors on windows are sane you can leave it that way. Otherwise, add this file to your svn config (optionally changing native to CRLF) ensuring consistent CRLF line endings through out.

Set autocrlf = input and change native to LF for consistently linux line endings throughout.

这篇关于git svn windows linux whitespace问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 14:50