git_subtree

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
git_subtree [2017/11/07 02:48] – [Setting up a subtree] rpjdaygit_subtree [2018/02/13 17:05] (current) – [Links] rpjday
Line 8: Line 8:
   * [[https://www.atlassian.com/blog/git/alternatives-to-git-submodule-git-subtree|Atlassian --    * [[https://www.atlassian.com/blog/git/alternatives-to-git-submodule-git-subtree|Atlassian -- 
 Git subtree: the alternative to Git submodule (2013)]] Git subtree: the alternative to Git submodule (2013)]]
-  * [[https://developer.atlassian.com/blog/2015/05/the-power-of-git-subtree/|The power of Git subtree (2015)]]+  * [[https://hpc.uni.lu/blog/2014/understanding-git-subtree/|Understanding Git subtree (2014)]] 
 +  * [[https://developer.atlassian.com/blog/2015/05/the-power-of-git-subtree/|Atlassian -- The power of Git subtree (2015)]]
   * [[https://medium.com/@porteneuve/mastering-git-subtrees-943d29a798ec|Mastering Git subtrees (2016)]]   * [[https://medium.com/@porteneuve/mastering-git-subtrees-943d29a798ec|Mastering Git subtrees (2016)]]
   * [[https://gist.github.com/kvnsmth/4688345|A real world usage for Git subtrees]]   * [[https://gist.github.com/kvnsmth/4688345|A real world usage for Git subtrees]]
Line 30: Line 31:
                
        ... snip ...        ... snip ...
 +       
 +DESCRIPTION
 +       Subtrees allow subprojects to be included within a subdirectory of the main project,
 +       optionally including the subproject’s entire history.
 +
 +       For example, you could include the source code for a library as a subdirectory of your
 +       application.
 +
 +       Subtrees are not to be confused with submodules, which are meant for the same task. Unlike
 +       submodules, subtrees do not need any special constructions (like .gitmodule files or
 +       gitlinks) be present in your repository, and do not force end-users of your repository to
 +       do anything special or to understand how subtrees work. A subtree is just a subdirectory
 +       that can be committed to, branched, and merged along with your project in any way you want.
 +       
 +       ... snip...
                
 OPTIONS OPTIONS
Line 126: Line 142:
  
 ==== To manually update subtree ==== ==== To manually update subtree ====
 +
 +Synopsis:
 +
 +<code>
 +$ git subtree pull -P <prefix> <repository> <ref>
 +</code>
 +
 +Example:
  
 <code> <code>
Line 131: Line 155:
   --prefix .vim/bundle/tpope-vim-surround \   --prefix .vim/bundle/tpope-vim-surround \
   https://bitbucket.org/vim-plugins-mirror/vim-surround.git \   https://bitbucket.org/vim-plugins-mirror/vim-surround.git \
 +  master \
 +  --squash
 +$
 +</code>
 +
 +==== Add the subproject as a remote ====
 +
 +Add a remote (''-f'' means fetch immediately):
 +
 +<code>
 +$ git remote add \
 +  -f \
 +  tpope-vim-surround \
 +  https://bitbucket.org/vim-plugins-mirror/vim-surround.git
 +$
 +</code>
 +
 +Add the subtree:
 +
 +<code>
 +$ git subtree add \
 +  --prefix .vim/bundle/tpope-vim-surround \
 +  tpope-vim-surround \
 +  master \
 +  --squash
 +$
 +</code>
 +
 +To update at a later date:
 +
 +<code>
 +$ git fetch tpope-vim-surround master
 +$ git subtree pull \
 +  --prefix .vim/bundle/tpope-vim-surround \
 +  tpope-vim-surround \
   master \   master \
   --squash   --squash
 $ $
 </code> </code>
  • git_subtree.1510022912.txt.gz
  • Last modified: 2017/11/07 02:48
  • by rpjday