#topicpath();
/////////////////////////////////////////////////////////////////////////////////
* 目次 [#c93151f1]
#contents();

/////////////////////////////////////////////////////////////////////////////////
* repo とは [#l4410761]
- 複数の git リポジトリからなる開発ツリーを一元管理しやすくするための、 git の wrapper のようなスクリプト
- Google がリリースしており、 Android の開発で使用されている
- [[本家(gitリポジトリ)>https://gerrit.googlesource.com/git-repo]]

/////////////////////////////////////////////////////////////////////////////////
* command [#df164ab5]
//===============================================================================
** forall -pvc <command-line> [#b54ed48a]
- repo 管理下にある全 repository に対してユーザが指定したコマンド <command-line> を実行する
 $ repo forall -pvc <command-line>
- <command-line> で複数のコマンドを実行したい場合は、ダブルクォートで括る
 # repo forall -pvc "git reset --hard HEAD; git pull --rebase"

//===============================================================================
** branches [#j26ed47a]
- repo 管理下にある全 repository の branch 状態を表示する

//===============================================================================
** checkout <branch-name> [#zd5d85c9]
- repo 管理下にある全 repository の branch を <branch-name> に切り替える

/////////////////////////////////////////////////////////////////////////////////
* 全 branch の切り替え [#f4b16870]
+ リポジトリ名を除いた branch 名で checkout する
 $ repo init -b <new-branch-name>
+ ひとまずファイル実体を全て消して、展開し直す
 $ rm -rf *;
 $ repo sync
 $ repo start <new-branch-name>




/////////////////////////////////////////////////////////////////////////////////
* manifest が更新されているかもしれない場合の更新方法 [#z134839c]
- repo sync では manifest は更新されない。
- manifest の branch が "default" になっていて且つ upstream が設定されていない場合は remote branch を upstream とする local branch を作るなどして更新できるようにする
-- 下記の前提として、${REPOS_ROOT} に .repo や各リポジトリの実体が配置されているものとする
-- manifest の更新
 $ cd ${REPOS_ROOT}/.repo/manifests
 $ git co -b <local-branch> <remote-branch>
 $ git pull
-- manifest からリポジトリのエントリが削除されている場合、 .repo 以下の cache の容量が気になるなら、 cache を一旦消して取り直す。
 $ cd ${REPOS_ROOT}/.repo
 $ rm -rf projects project-objects;  # cache の削除。これを実行すると次の repo sync ではある程度余計に時間が掛かる。
-- manifest で管理されている各リポジトリの更新
 $ cd ${REPOS_ROOT}
 $ rm -rf *       # .repo 以外を全て消す。 manifest から削除された物がある場合には必要な手順となる
 $ repo sync      # ここで、 checkout 済の branch があっても、場合によってはその branch から detach されることがある。
 $ repo forall "git checkout <local-branch>; git fetch --unshallow; git fetch --all; git merge"
-- "--unshallow" オプションは、 git pull でも使用出来る。このオプションは、 manifest に ''clone-depth="1"'' と記述されてるリポジトリに対して、他の通常のリポジトリと同様、最新まで全ての履歴を local に取得しようとする。 clone-depth が指定されているリポジトリがなければ実行しなくてよい。


/////////////////////////////////////////////////////////////////////////////////
* 「リポジトリが壊れたかな?」というときは [#a4ed1b8a]
- repo 管理下に、例えば hoge なるリポジトリがあったとすると、これは、 repo init, repo sync で取ってきたコードツリー上では
 hoge/.git/
の中身が
 .repo/projects/<manifestで指定されたパス>/hoge.git
 .repo/project-objects/<manifestで指定されたパス>/hoge.git
配下への SymLink になっており、上記2つの hoge.git 両方揃って初めて完全なリポジトリと同じ状態になるようにできている。~
これらが壊れている場合は、以下を実行する。~
但し、ローカルに commit して他所へ push していないものは消えてしまうので要注意。
 $ rm -rf projects project-objects;  # cache の削除
- 逆に言うと、リポジトリとしての実体は .repo 配下にあるため、commit してある修正に関しては、 .repo の外にある hoge を rm -Rf で消してもなくならない。




/////////////////////////////////////////////////////////////////////////////////
* Links [#sabd22ce]
- [[repo のコマンド>http://uenoshin.hatenablog.com/entry/2013/12/20/222419]]
- [[git管理ツールRepoを入れてみよう>http://qiita.com/fuuuuumin65/items/12310745a0d3c2319fe1]]
- [[Repo を使う --- Manifest ファイルの書き方>http://at-aka.blogspot.jp/2009/02/repo-manifest.html]]

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS