Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| git_subtree [2017/11/07 02:35] – [Links] rpjday | git_subtree [2018/02/13 17:05] (current) – [Links] rpjday | ||
|---|---|---|---|
| Line 8: | Line 8: | ||
| * [[https:// | * [[https:// | ||
| Git subtree: the alternative to Git submodule (2013)]] | Git subtree: the alternative to Git submodule (2013)]] | ||
| - | * [[https:// | + | |
| + | | ||
| * [[https:// | * [[https:// | ||
| * [[https:// | * [[https:// | ||
| Line 30: | Line 31: | ||
| ... snip ... | ... snip ... | ||
| + | |||
| + | DESCRIPTION | ||
| + | | ||
| + | | ||
| + | |||
| + | For example, you could include the source code for a library as a subdirectory of your | ||
| + | | ||
| + | |||
| + | | ||
| + | | ||
| + | | ||
| + | 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 47: | Line 63: | ||
| </ | </ | ||
| - | ==== Example | + | ==== The good and the bad ==== |
| + | |||
| + | The good: | ||
| + | |||
| + | * Management of a simple workflow is easy. | ||
| + | * Older version of Git are supported (even older than v1.5.2). | ||
| + | * The sub-project’s code is available right after the clone of the super project is done. | ||
| + | * '' | ||
| + | * '' | ||
| + | * Contents of the module can be modified without having a separate repository copy of the dependency somewhere else. | ||
| + | |||
| + | The bad: | ||
| + | |||
| + | * You must learn about a new merge strategy (i.e. git subtree). | ||
| + | * Contributing code back upstream for the sub-projects is slightly more complicated. | ||
| + | * The responsibility of not mixing super and sub-project code in commits lies with you | ||
| + | |||
| + | |||
| + | ==== Setting up a subtree | ||
| === Start a new branch === | === Start a new branch === | ||
| Line 56: | Line 90: | ||
| === Start a subtree, and examine it === | === Start a subtree, and examine it === | ||
| + | |||
| + | The synopsis: | ||
| + | |||
| + | < | ||
| + | $ git subtree add -P < | ||
| + | </ | ||
| + | |||
| + | The example: | ||
| < | < | ||
| Line 99: | Line 141: | ||
| </ | </ | ||
| - | === To manually update subtree === | + | ==== To manually update subtree ==== |
| + | |||
| + | Synopsis: | ||
| + | |||
| + | < | ||
| + | $ git subtree pull -P < | ||
| + | </ | ||
| + | |||
| + | Example: | ||
| < | < | ||
| Line 105: | Line 155: | ||
| --prefix .vim/ | --prefix .vim/ | ||
| https:// | https:// | ||
| + | master \ | ||
| + | --squash | ||
| + | $ | ||
| + | </ | ||
| + | |||
| + | ==== Add the subproject as a remote ==== | ||
| + | |||
| + | Add a remote ('' | ||
| + | |||
| + | < | ||
| + | $ git remote add \ | ||
| + | -f \ | ||
| + | tpope-vim-surround \ | ||
| + | https:// | ||
| + | $ | ||
| + | </ | ||
| + | |||
| + | Add the subtree: | ||
| + | |||
| + | < | ||
| + | $ git subtree add \ | ||
| + | --prefix .vim/ | ||
| + | tpope-vim-surround \ | ||
| + | master \ | ||
| + | --squash | ||
| + | $ | ||
| + | </ | ||
| + | |||
| + | To update at a later date: | ||
| + | |||
| + | < | ||
| + | $ git fetch tpope-vim-surround master | ||
| + | $ git subtree pull \ | ||
| + | --prefix .vim/ | ||
| + | tpope-vim-surround \ | ||
| master \ | master \ | ||
| --squash | --squash | ||
| $ | $ | ||
| </ | </ | ||