2010-02-24 80 views
5

我在Linux上使用git(與git-svn),同事在windows上使用svn。git svn windows linux whitespace問題

很多次,git報告空白問題。事實上,由於這些問題而無法提交線性歷史記錄,並造成合並衝突。

在windows和linux上配置svn/git和git-svn的最簡單方法是什麼,以便現在有空白問題?

以下是報告的合併衝突,在一個線性的歷史上主:

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". 

如何解決這個問題的空白?

回答

11

修復空白錯誤

一下添加到.gitconfig

[core] 
    whitespace=nowarn 

git的重訂,現在應該工作。 (您可以選擇添加一些fix,-indent-with-non-tab,trailing-space到有混帳解決所有的空格,在每一個提交。這是否是一個好主意,取決於項目的規則和團隊。)

修復EOL錯誤

[core] 
    autocrlf = true 

在您的.gitconfig。這將強制每個文本文件具有窗口行結束符。 svn默認情況下會忽略行結束符,並且如果窗口上的文本編輯器是正常的,則可以使用這種方式。否則,請將this file添加到您的svn配置(可選更改nativeCRLF),以確保CRLF行結束始終一致。

設置autocrlf = input並更改nativeLF爲始終如一的Linux行結束。