I found those blogs http://blogs.atlassian.com/2013/05/alternatives-to-git-submodule-git-subtree and http://endot.org/2011/05/18/git-submodules-vs-subtrees-for-vim-plugins/ about how to use Git subtree. It seems straight forward, but I actually encountered a lot of errors before I successfully created one.
- You need to create a git repository using 'git init' in the dir you want to have all plugins before running 'git subtree'.
[ben@localhost vim-plugins]$ git subtree add --prefix ./vim-pathogen https://github.com/tpope/vim-pathogen.git master --squash
fatal: Not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
[ben@localhost vim-plugins]$ git init
Initialized empty Git repository in /home/ben/git/vim-plugins/.git/ - You have to have at least one commit.
[ben@localhost vim-plugins]$ git subtree add --prefix ./vim-pathogen https://github.com/tpope/vim-pathogen.git master --squash
fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git[ ...] -- [ ...]'
Working tree has modifications. Cannot add.
[ben@localhost vim-plugins]$ vi README.md
[ben@localhost vim-plugins]$ git add .
[ben@localhost vim-plugins]$ git commit -m "initial commit"
[master (root-commit) 70de380] initial commit
1 file changed, 2 insertions(+)
create mode 100644 README.md - Then you might see this error. What's wrong? Don't use any path './'. I tried '$PWD/vim-pathogen', the same error. I'm using Git 1.8.3 on Fedora 19. Not sure it is a version issue or not.
[ben@localhost vim-plugins]$ git subtree add --prefix ./vim-pathogen https://github.com/tpope/vim-pathogen.git master
git fetch https://github.com/tpope/vim-pathogen.git master
warning: no common commits
remote: Counting objects: 499, done.
remote: Compressing objects: 100% (235/235), done.
remote: Total 499 (delta 148), reused 499 (delta 148)
Receiving objects: 100% (499/499), 82.10 KiB | 0 bytes/s, done.
Resolving deltas: 100% (148/148), done.
From https://github.com/tpope/vim-pathogen
* branch master -> FETCH_HEAD
error: Invalid path './vim-pathogen/CONTRIBUTING.markdown'
error: Invalid path './vim-pathogen/README.markdown'
error: Invalid path './vim-pathogen/autoload/pathogen.vim'
error: pathspec 'vim-pathogen' did not match any file(s) known to git.
[ben@localhost vim-plugins]$ git subtree add --prefix vim-pathogen https://github.com/tpope/vim-pathogen.git master
git fetch https://github.com/tpope/vim-pathogen.git master
From https://github.com/tpope/vim-pathogen
* branch master -> FETCH_HEAD
Added dir 'vim-pathogen' - You can define a repository using 'git remote add', then use name instead of the url.
[ben@localhost vim-plugins]$ git remote add hive https://github.com/autowitch/hive.vim.git
[ben@localhost vim-plugins]$ git subtree add -P hive.vim hive master
git fetch hive master
From https://github.com/autowitch/hive.vim
* branch master -> FETCH_HEAD
Added dir 'hive.vim' - You may not use 'tabular/master' unless you fetch tabular.
[ben@localhost vim-plugins]$ git remote add tabular https://github.com/godlygeek/tabular.git
[ben@localhost vim-plugins]$ git subtree add -P tabular tabular/master
'tabular/master' does not refer to a commit
[ben@localhost vim-plugins]$ git fetch tabular
warning: no common commits
remote: Reusing existing pack: 131, done.
remote: Total 131 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (131/131), 32.36 KiB | 0 bytes/s, done.
Resolving deltas: 100% (48/48), done.
From https://github.com/godlygeek/tabular
* [new branch] gtabularize -> tabular/gtabularize
* [new branch] master -> tabular/master
* [new branch] pattern_reuse -> tabular/pattern_reuse
* [new branch] trim_1st_field -> tabular/trim_1st_field
[ben@localhost vim-plugins]$ git subtree add -P tabular tabular/master
Added dir 'tabular' - create a file under ~/git/vim-plugins/.vimrc like below. Then make a symlink to ~/.vimrc.
source ~/git/vim-plugins/vim-pathogen/autoload/pathogen.vim
execute pathogen#infect('~/git/vim-plugins/{}')
syntax on
filetype plugin indent on
set sw=2
augroup filetypedetect
au BufNewFile,BufRead *.pig set filetype=pig syntax=pig
au BufNewFile,BufRead *.hql set filetype=hive syntax=hive
augroup END - qgit works with subtree.
- Because you have to add '--prefix name' in subtree command, you cannot pull all repos. There is not 'git subtree pull-all' yet, see http://ruleant.blogspot.nl/2013/06/git-subtree-module-with-gittrees-config.html.