SVN衝突解決方法

原因

由於上週五改了代碼,但是下班的時候忘記提交SVN了,然後週末趕着上線,所以在家裏加班,改了代碼,換了圖片,整理完成後,打包提交了。

然後,今天到公司,想要同步下,執行了下svn update,然後,衝突就出現了!

因此:出現了兩種類型的衝突。

  1. tree conflict
    說明兩次提交,修改了目錄結構,包括文件或者文件所在目錄的改名、刪除、移動。
    因爲兩次代碼實現不同第二次添加了category,所以才造成了這個問題。

  2. text conflict

    1. 由於我在項目中添加了運行自增腳本,所以,項目的build是不一樣的。
    2. 兩次代碼實現方式不同。
    3. 同一個位置,圖片不同。

解決

  1. tree conflict
    update的時候直接添加了。

  2. text conflict

    • 代碼這個不用說了,也是直接更新了,如果出現同一個文件,同一個位置,改動不同,則會出現:

      <<<<<< confliceFileName
      
      content1
      ==========
      
      content2
      >>>>>>>>    

      留下需要的內容,刪除不需要的,解決

    • 版本號的問題
      xcode使用的是plist類型文件,不過沒有別的,本質上也是xml, open in source code,解決方法同上!
      PS:
      刪除之後,使用指令svn resolved [file]來標記衝突解決。

    • 這裏要特別說下圖片的問題了!
      默認情況下,同名圖片,更新的時候,後來更行的是會直接替換原圖,所以會出現相應的英文提示。然後執行上面所說的svn resolved指令的時候,會出現一些問題(以名爲btn@2x的圖片爲例):

      svn resolved 項目名/圖片資源文件夾名字/btn@2x
      然後,svn會報錯!
      E200009: '項目名/圖片文件夾名/[email protected]': a peg revision is not allowed here

      解決:
      在圖片的後邊加個@即可:
      svn resolved 項目名/圖片文件夾名/[email protected]@

      From the SVN book (emphasis added):
      
      The perceptive reader is probably wondering at this point whether the peg revision syntax 
      causes problems for working copy paths or URLs that actually have at signs in them. 
      After all, how does svn know whether news@11 is the name of a directory in my tree 
      or just a syntax for “revision 11 of news”? Thankfully, 
      while svn will always assume the latter, there is a trivial workaround. 
      You need only append an at sign to the end of the path, 
      such as news@11@. svn cares only about the last at sign in the argument, 
      and it is not considered illegal to omit a literal peg revision specifier after that at sign. 
      This workaround even applies to paths that end in an at sign—you would use filename@@ 
      to talk about a file named filename@.

      也可以參考stackoverflow

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章