====== SourceTreeで「subtree」を使う ====== git subtreeは外部のリポジトリを現在のリポジトリに取り込むための機能。 T-Kernelプロジェクトで共通なソースの受け渡しにsubtreeを使っている。SourceTreeで、subtreeを使う手順の備忘録を残す。 ===== subtreeの追加 ===== (1) 左側で右クリックし、「サブツリーの追加/リンク...」をクリック {{software:sourcetree:sourcetree-subtree-01.png?400}} (2) サブツリーの情報入力 {{software:sourcetree:sourcetree-subtree-02.png}} ===== 「Working tree has modifications. Cannot add.」エラー対応 ===== サブツリーのプルを実行すると「`Working tree has modifications. Cannot add.`」エラーが発生。 調べてみると(参考.3)、どうもGitのバグらしく、一度別のブランチに切り替えて元のブランチに戻り、サブツリーのプルを実行すると実行できた。 ===== 補足 ===== * ローカル相対パスのフォルダ区切り文字は、`¥`ではなく`/`を使わないと変になる。 * SourceTreeでのsubtreeのリンク情報は、「`.git/sourcetreeconfig`」に記録される。 ### Gitコマンドで追加する手順 ``` $ git subtree add --prefix=v100/OPT --squash git@sample.com:prog/tk-optsys.git master ``` * この時、追加先のフォルダは存在しているとエラーになるので、ない状態で実行する。 ===== 参考 ===== - [Git Subtree 事始め](https://qiita.com/mikakane/items/487ca8b3acddfa5fdb41) - [【手順】git subtreeコマンドの使い方](https://qiita.com/takahashi-kazuki/items/0c34b3bc5da6700d38a5) - [git subtree pull says that the working tree has modifications, but git status says it doesn't. What gives? ](https://stackoverflow.com/questions/3623351/git-subtree-pull-says-that-the-working-tree-has-modifications-but-git-status-sa)