git subtree split

方健發表於2014-05-29
jk:second_screen fangjian$ tree -L 1 .
.
├── android
├── iphone
├── server
└── wav

4 directories, 0 files

git subtree split --prefix=android -b android
git subtree split --prefix=iphone -b ios
git subtree split --prefix=wav -b wav
git subtree split --prefix=server -b server

git push origin ios:ios git push origin android:android git push origin server:server git push origin wav:wav

切換到android分支
git checkout android

git clone預設會把遠端倉庫整個給clone下來 但只會在本地預設建立一個master分支 如果遠端還有其他的分支,此時用git branch -a檢視所有分支

[root@host second_screen]# git branch -a
  master
* server
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/server

git checkout -t origin/server

[root@host second_screen]# git branch
  master
* server

或者
git clone -b wav git@192.168.1.203:project/second_screen.git wav

組合

http://stackoverflow.com/questions/16829401/adding-git-subtree-from-a-branch

$ git remote add cow https://github.com/geoffryan/cow.git
$ git fetch cow
$ git subtree add -P cow cow/stable --squash
Added dir 'cow'

相關文章