iOS開發XCODE5 SVN配置 使用辦法

來源:互聯網
上載者:User

標籤:des   style   blog   http   color   os   使用   io   strong   

  第一次弄svn版本控制,折騰了好久一直都出錯!無意間看到一篇文章!貌似解決了,很感謝“代碼妖嬈” 的詳細流程(http://blog.sina.com.cn/s/blog_68661bd80101phpy.html)!在此為只記錄下給我解決的問題。

 

   

這兩天響應老闆要求,把所有代碼放到公司的SVN伺服器上,按照我的想法肯定是就蘋果組建一個伺服器,然後組建控制,內建的Xcode就有這個功能,之前也這麼做過,但是xcode4.X系列SVN還是很好用,自從升級到Xcode5之後還沒弄過。今天試了一下午還是沒完全明白,眼看弄不出來,就直接用命令列了,不過一些簡單的東西還是試出來了。

1.如何使用Xcode5  SVN從公司伺服器 check out項目

  1. Choose Source Control > Check Out.

  2. Select the repository you want to check out, and click Next.

    You can select your repository from the Repositories tab, the Favorites tab, or the Recents tab. If you know the location of the repository you want to check out, you can also enter the address manually.

  3. If Xcode is unable to automatically identify the trunk and branches, use the browser window to select the correct project location, and click Next.

  4. In the Checkout window, select the branches and working copies to check out, and click Next.

    You will be presented only with the necessary options for your repository. If your project contains only one working copy, you will only have to select the branch to checkout. If your project doesn’t contain branches, you will only be given an option of working copies to checkout. If you project is a single working copy with no branches, this dialog will be skipped entirely.

  5. Select the location to store the working copy, and click Check Out.



2.當有修改時,在Source Control裡面可以做點什麼,我試了下commit,可以提交到本地,但是沒有提交到伺服器,中間包括-1012錯誤,然後配置git使用者名稱跟郵箱。然後填寫版本注釋,然後就提交,看似提交成功,伺服器上卻沒有。

 

3.Push local changes:我點擊了試試,就出來下面這個,我有點疑惑,後來發現人家是

 push local changes to a remote git repository 



然後我就有點懷疑,難道Xcode內建的SVN的subversion類型不支援提交到伺服器這個功能麼。

然後看協助文檔,有這麼一句。

If you’re using Subversion, a commit operation copies the changes from selected files into the remote Subversion repository. Therefore, you must be connected to the repository before you can commit changes. (For details, see your repository administrator.)

搞了半天不懂 see your repository administrator是什麼意思。翻譯出來是庫管理員。我只想說看他有個毛用。我自能默默自嘲英文差。

 

4.然後我就想著再繼續往下看。Updating or Pulling Changes from a Repository

如何更新和提交更改。然後就看到下面的內容。

Update your project with changes from the repository using the Source Control menu.

  • For a Git repository, choose Source Control > Pull.

  • For a Subversion repository, choose Source Control > Update.

  • For a project that contains both Git and Subversion repositories, choose Source Control > Update and Pull.

For projects with multiple repositories, select the ones you want to update.

Resolve differences by using the left and right buttons to specify which file’s contents to use.

After reconciling all differences, click Pull (Git) or Update (SVN) to complete the operation.

開啟Source Control就沒有找到Pull和Update。本來就英文差,他媽的剛巧就認得這幾句,然後就此作罷。大牛莫要嘲笑我,還請告知我是哪裡出了問題。

看了一個問答,XCODE5中怎麼上傳到SVN伺服器,老外給出的結論是:兩個辦法,一個是用svn client,用戶端軟體;另一個方法是命令列。One way is using an svn client. The one which is obviously available is the command line svn client.

http://stackoverflow.com/questions/18894195/xcode-5-export-project-to-svn-repository

 

但是事情不能不做,就在網上找了命令實驗了一下,儘可能寫的詳細點,下次看的時候好懂。隨便幫幫跟我一樣正在鬱悶的人。

 

 

 

 

1.更改配置(不懂的話就直接跳過吧)

bogon:~ chenshuangchou$ open ~/.subversion/config

啟動設定檔,然後在設定檔中選擇要忽略的檔案類型

找到 global-ignores 一行,去掉注釋,編輯成

global-ignores = build *~.nib *.so *.pbxuser *.mode *.perspective*

# global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo

(我解決的是用一下兩句,不然我那邊會錯的)

#global-ignores = build *~.nib *.so *.pbxuser *.mode *.perspective*

# global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo

 

找到 enable-auto-props = yes 把注釋去掉,在[auto-props] Section聲明以下文字檔

*.mode* = svn:mime-type=text/X-xcode

*.pbxuser = svn:mime-type=text/X-xcode

*.perspective* = svn:mime-type=text/X-xcode

*.pbxproj = svn:mime-type=text/X-xcode

(我解決的是一下代碼:) 

#*.mode* = svn:mime-type=text/X-xcode

#*.pbxuser = svn:mime-type=text/X-xcode

# *.perspective* = svn:mime-type=text/X-xcode

# *.pbxproj = svn:mime-type=text/X-xcode

2.import命令

首先將本地代碼import到版本庫

bogon:~ chenshuangchou$ svn import /Users/chenshuangchou/Desktop/BuickIOS/Buickhousekeeper  https://192.168.21.248:8443/svn/BuickIOS/ -m "initial import"

 

3.checkout命令

然後從版本庫checkout出來,這個目錄就相當於被啟用,內部跟伺服器位址關聯。

bogon:~ chenshuangchou$svn checkout https://192.168.21.248:8443/svn/BuickIOS/ /Users/chenshuangchou/Desktop/BuickIOS

 

 

4.add命令

當有新增的檔案時用add指令,增加到版本庫,然後提交

svn add /Users/chenshuangchou/Desktop/BuickIOS/Buickhousekeeper/ViewControllers/CarViewController/FuelManageViewController/lastmouth_color1.png 

執行這條指令的前提是/Users/chenshuangchou/Desktop/BuickIOS/是從伺服器checkout下來的目錄,也就是is a working copy

新增成功的話會有

A  (bin)  Desktop/BuickIOS/Buickhousekeeper/ViewControllers/CarViewController/FuelManageViewController/lastmouth_color1.png

 

 

5.commit命令

提交內容到版本庫

bogon:~ chenshuangchou$ svn commit -m "添加了一個油耗柱狀圖"/Users/chenshuangchou/Desktop/BuickIOS/Buickhousekeeper/ViewControllers/CarViewController/FuelManageViewController/lastmouth_color1.png

提交到版本庫成功的話,

Adding  (bin) Desktop/BuickIOS/Buickhousekeeper/ViewControllers/CarViewController/FuelManageViewController/lastmouth_color1.png

Transmitting file data .

Committed revision 3.

 

 

 

6.update命令

更新版本庫到本地,更新指定目錄,svn update如果後面沒有目錄,預設將目前的目錄以及子目錄下的所有檔案都更新到最新版本。

bogon:~ chenshuangchou$ svn update /Users/chenshuangchou/Desktop/BuickIOS1

更新成功

Updating ‘Desktop/BuickIOS1‘:

A    Desktop/BuickIOS1/Buickhousekeeper/ViewControllers/CarViewController/FuelManageViewController/lastmouth_color1.png

Updated to revision 3.

 

回退到版本2:    

bogon:~ chenshuangchou$ svn update -r 2 Desktop/BuickIOS1/

回退成功的話

Updating ‘Desktop/BuickIOS1‘:

D    Desktop/BuickIOS1/Buickhousekeeper/ViewControllers/CarViewController/FuelManageViewController/lastmouth_color1.png

Updated to revision 2.

 

衝突

(更新,於版本庫同步。如果在提交的時候提示到期的話,是因為衝突,需要先update,修改檔案 ,然後清除svn resolved ,最後再提交commit)

在提交時發生版本衝突會怎麼樣

bogon:~ chenshuangchou$ svn commit -m "在delegate中加入了一句話" /Users/chenshuangchou/Desktop/BuickIOS/

Sending        Desktop/BuickIOS/.git/index

Sending        Desktop/BuickIOS/Buickhousekeeper/AppDelegate.h

Sending       Desktop/BuickIOS/Buickhousekeeper.xcodeproj/project.xcworkspace/xcuserdata/chenshuangchou.xcuserdatad/UserInterfaceState.xcuserstate

Transmitting file data ...

Committed revision 4.

bogon:~ chenshuangchou$ svn commit -m "在delegate中加入了一句不同的話" /Users/chenshuangchou/Desktop/BuickIOS1/

Sending        Desktop/BuickIOS1/.git/index

svn: E160042: Commit failed (details follow):

svn: E160042: File or directory ‘.git/index‘ is out of date; try updating

svn: E160024: resource out of date; try updating

out   of  date表示版本到期,可能是由於另外的開發人員更新了伺服器版本,而本地代碼與伺服器衝突

 

遇到這種情況,應該先從伺服器update一下,然後再提交

bogon:~ chenshuangchou$ svn update  Desktop/BuickIOS1/

Updating ‘Desktop/BuickIOS1‘:

Conflict discovered in ‘/Users/chenshuangchou/Desktop/BuickIOS1/.git/index‘.

Select: (p) postpone,

        (mf) mine-full, (tf) theirs-full,

        (s) show all options: 

在這裡會有一個選擇,選擇(s)會顯示所有選項的所有注釋,如下

(s)  show all    - show this list

(e)  edit             - change merged file in an editor

(df) diff-full        - show all changes made to merged file

(r)  resolved         - accept merged version of file

(dc) display-conflict - show all conflicts (ignoring merged version)

(mc) mine-conflict    - accept my version for all conflicts (same)

(tc) theirs-conflict  - accept their version for all conflicts (same)

(p) postpone  - mark the conflict to be resolved later。

(mf) mine-full  - accept my version of entire file (even non-conflicts)

(tf) theirs-full      - accept their version of entire file (same)

選擇一個之後會繼續顯示衝突點,直到完。而每一個點都會詢問怎麼處理。

G   Desktop/BuickIOS1/Buickhousekeeper.xcodeproj/project.xcworkspace/xcuserdata/chenshuangchou.xcuserdatad/UserInterfaceState.xcuserstate

Conflict discovered in ‘/Users/chenshuangchou/Desktop/BuickIOS1/Buickhousekeeper/AppDelegate.h‘.

Select: (p) postpone, (df) diff-full, (e) edit,

        (mc) mine-conflict, (tc) theirs-conflict,

        (s) show all options: tf

G    Desktop/BuickIOS1/Buickhousekeeper/AppDelegate.h

Updated to revision 4.

選擇tf之後,衝突點會被伺服器上的代碼覆蓋,自己本地代碼會永久不見。最好先選擇postpone,確定之後再修改。

關於衝突,可以參考:http://www.logicaltrinkets.com/wordpress/?p=178

 

 

 

 

7.status命令

查看檔案或者目錄狀態

svn status path (目錄下的檔案和子目錄的狀態,正常狀態不顯示)

?:不在svn的控制中;M:內容被修改;C:發生衝突;A:預定加入到版本庫;K:被鎖定

svn status -v path 顯示所有檔案的修改資訊,在查看狀態的同時,顯示本地目前的版本號,最後一次修改的版本號碼和修改人,分別在前

bogon:~ chenshuangchou$ svn status  Desktop/BuickIOS1/

M       Desktop/BuickIOS1/.git/index

?       Desktop/BuickIOS1/.git/objects/1c/7d8324a67dcd866bd0b4122b01b924a0e77128

?       Desktop/BuickIOS1/.git/objects/75/1826a72a4afd4b15faf73a0b6e4166d3bbec01

?       Desktop/BuickIOS1/.git/objects/a4/1c23190a65cda6a64a95bef22a9264ad64d90e

?       Desktop/BuickIOS1/.git/objects/b3/df5dbb592745d9744adf7a32ed2bb39370c78e

M       Desktop/BuickIOS1/Buickhousekeeper/AppDelegate.h

?       Desktop/BuickIOS1/Buickhousekeeper/lastmouth_color1.png

?       Desktop/BuickIOS1/Buickhousekeeper/lastmouth_color2.png

?       Desktop/BuickIOS1/Buickhousekeeper/lastmouth_color3.png

?       Desktop/BuickIOS1/Buickhousekeeper/lastmouth_color4.png

M       Desktop/BuickIOS1/Buickhousekeeper.xcodeproj/project.pbxproj

M      Desktop/BuickIOS1/Buickhousekeeper.xcodeproj/project.xcworkspace/xcuserdata/chenshuangchou.xcuserdatad/UserInterfaceState.xcuserstate

 

 

8.delete命令

svn delete path -m " delete test fle " 

刪除一個空白的檔案夾:

bogon:~ chenshuangchou$ svn delete /Users/chenshuangchou/Desktop/BuickIOS/branches 

D         Desktop/BuickIOS/branches

顯示刪除成功

 

 

 

9.log命令

查看版本記錄,也叫日誌

bogon:~ chenshuangchou$ svn log /Users/chenshuangchou/Desktop/BuickIOS

------------------------------------------------------------------------

r3 | chensc | 2013-10-31 11:34:03 +0800 (四, 31 10 2013) | 1 line

 

添加了一個油耗柱狀圖

------------------------------------------------------------------------

r2 | chensc | 2013-10-28 12:00:36 +0800 (一, 28 10 2013) | 1 line

 

initial import

------------------------------------------------------------------------

r1 | VisualSVN Server | 2013-06-28 17:40:29 +0800 (五, 28  6 2013) | 1 line

 

Initial structure.

 

只有兩個版本記錄,說明第二個版本和第三個版本未添加版本說明,也就是在執行指令時未添加-m  ,這個指令是添加註釋

 

 

10.diff命令

svn diff path(將修改的檔案與基礎版本比較)

在上傳版本時,可能有自己版本與伺服器版本不一致,需要查看具體代碼,這個命令就可以做到

svn diff -r m:n path

對版本m和版本n比較差異

在追溯版本問題時,這個命令也十分有用

bogon:~ chenshuangchou$ svn diff /Users/chenshuangchou/Desktop/BuickIOS1

--- /Users/chenshuangchou/Desktop/BuickIOS1/Buickhousekeeper/AppDelegate.h (revision 4)

+++ /Users/chenshuangchou/Desktop/BuickIOS1/Buickhousekeeper/AppDelegate.h (working copy)

@@ -6,6 +6,7 @@

 //  Copyright (c) 2013年 calinks. All rights reserved.

 //測試的很好

 

+

 #import

 #import "BMapKit.h"

 

@@ -15,7 +16,7 @@

 - (void)refreshIdeaMessage;

 

 - (void)refreshMaintainMessage;

[email protected]

[email protected] 

 

 

 

 

11.merge命令

將兩個版本之間的差異合并到當前檔案

bogon:BuickIOS chenshuangchou$ svn merge -r 4:5 /Users/chenshuangchou/Desktop/BuickIOS/Buickhousekeeper/AppDelegate.h

一般會發生衝突,處理衝突

— /Users/chenshuangchou/Desktop/BuickIOS/Buickhousekeeper/svn-1FUb4k 四 10 31 15:36:15 2013

+++ /Users/chenshuangchou/Desktop/BuickIOS/.svn/tmp/AppDelegate.h.tmp 四 10 31 15:36:16 2013

@@ -4,8 +4,13 @@

 //  Copyright (c) 2013年 calinks. All rights reserved.

-//測試的很好

+<<<<<<< .working

+//測試一下

+=======

+//驗證版本差異合并

+>>>>>>> .merge-right.r5

 

 

 

 

12.ls命令

版本庫下的檔案和目錄列表

svn list path顯示path目錄下的所有屬於版本庫的檔案和目錄

bogon:BuickIOS chenshuangchou$ svn ls https://192.168.21.248:8443/svn/BuickIOS/

.git/

Buickhousekeeper/

Buickhousekeeper.xcodeproj/

DevOneSDK.framework/

branches/

tags/

trunk/

 

 

 

 

 

13.log命令

查看檔案詳細資料

bogon:~ chenshuangchou$ svn info /Users/chenshuangchou/Desktop/BuickIOS/Buickhousekeeper/AppDelegate.h 

Path: Desktop/BuickIOS/Buickhousekeeper/AppDelegate.h

Name: AppDelegate.h

Working Copy Root Path: /Users/chenshuangchou/Desktop/BuickIOS

URL: https://[email protected]:8443/svn/BuickIOS/Buickhousekeeper/AppDelegate.h

Repository Root: https://[email protected]:8443/svn/BuickIOS

Repository UUID: 9a03820f-37b7-b94a-a594-74c58a350bc6

Revision: 4

Node Kind: file

Schedule: normal

Last Changed Author: chensc

Last Changed Rev: 4

Last Changed Date: 2013-10-31 14:04:51 +0800 (四, 31 10 2013)

Text Last Updated: 2013-10-31 14:02:51 +0800 (四, 31 10 2013)

Checksum: 83d8a08d317af33501b650517aa4033d5fe9f0d4

 

14.其它命令

svn mkdir : 建立納入版本控制下的新目錄。

用法: 1、mkdir PATH...

2、mkdir URL...

svn revert : 恢複原始未改變的工作複本檔案 (恢複大部份的本地修改)。revert:

用法: revert PATH...

注意: 本子命令不會存取網路,並且會解除衝突的狀況。但是它不會恢複

被刪除的目錄

svn switch (sw): 更新工作複本至不同的URL。

用法: 1、switch URL [PATH]

     2、switch --relocate FROM TO [PATH...]

svn resolved: 移除工作複本的目錄或檔案的“衝突”狀態。

用法: resolved PATH...

注意: 本子命令不會依文法來解決衝突或是移除衝突標記;它只是移除衝突的

相關檔案,然後讓 PATH 可以再次提交。

svn cat 輸出指定檔案或URL的內容。

svn cat 目標[@版本]...如果指定了版本,將從指定的版本開始尋找。

svn cat -r PREV filename > filename (PREV 是上一版本,也可以寫具體版本號碼,這樣輸出結果是可以提交的)

 

iOS開發XCODE5 SVN配置 使用辦法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.