1、檢出代碼,指定git指定的分支和manifest
repo init -u git://xxx/xxx/manifest.git -b <BRANCH> -m <MANIFEST>
這里-m和-b的含義是:
1. 注意到manifest.git本身也是一個git project
2. 所以,-b指定的是使用#1中這個git project的哪個branch
3. -m指定的是,下載該git project中的哪個文件(應該是首先切換了branch,然后再下載該文件)。
repo init這樣做過了之后,其實本地就建立起來了一個.repo目錄,里面核心文件就是manifest.xml,這個xml中就定義了:
- 包含哪些git project
- 每個git project使用什么branch
- 每個git project在本地磁盤上的路徑和遠端服務器上該git project的路徑。?
事實上,當repo init完成,在本地的.repo/manifests目錄下就可以看到manifest這個git project,可以用git branch -av來查看branch,用git log來查看日志。?
2、創建并切換所有分支
git start my_branch --all
my_branch 是你想要創建的分支名稱
3、切換分支,默認是切換所有倉庫中的分支
repo checkout 分支名稱?
4、repo forall 對所有分支循環執行 ,git reset --hard HEAD 強制撤銷本地所有改動,恢復最新代碼
repo forall -c ?"git reset --hard HEAD"
等同于手動cd到所有分支目錄,執行git reset --hard HEAD
5、刪除分支
?repo abandon xxx?
xxx是分支名稱
6、同步遠程最新代碼
repo sync -d -c --no-tags
-c 的意思是只下載manifest中定義的當前分支,不下載其他分支,manifest中默認會開啟 -c
-d 的意思脫離本地分支,切換到服務器的分支,前提是本地代碼要clean
--no-tags 不下載 tag,可以減少時間,節省空間,一般情況下我們也用不到tag