Questions tagged [git-subtree]

An alternative to the git-submodule command. Merges and splits subtrees from your project into subprojects and back. git-subtree has been merged into mainline git as of 1.7.11.

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.

They are also not to be confused with using the subtree merge strategy. The main difference is that, besides merging the other project as a subdirectory, you can also extract the entire history of a subdirectory from your project and make it into a standalone project. Unlike the subtree merge strategy you can alternate back and forth between these two operations. If the standalone library gets updated, you can automatically merge the changes into your project; if you update the library inside your project, you can "split" the changes back out again and merge them back into the library project.

For example, if a library you made for one application ends up being useful elsewhere, you can extract its entire history and publish that as its own git repository, without accidentally intermingling the history of your application project.

Note that git subtree is not an official Git command, it is a script in the contrib/ directory of the Git repository of the Git project. Some distributions do install it along with the rest of Git, though.

544 questions
-1
votes
1 answer

Rebase into a subtree

The situation is that we have two repositories, parent and child. The parent repo has the child repo as a subtree: parent/ child/ After some time, the child repository has diverged from its upstream (patches have been made for use of the parent…
CLOVIS
  • 771
  • 8
  • 24
-1
votes
1 answer

Heroku - problem with git subtree push to a remote Heroku app

Per advise from Heroku - push subtrees to different apps I'm trying to push a local dist folder to one of my Heroku Node apps. However, I can't get it to work for my case. I issued first the command: git remote add myherokuapp…
-1
votes
1 answer

Why does git subtree prevent init-ing embedded submodules?

I have a git repository that I keep my vim configuration in. This tree includes a number of git submodules that refer to other people's repos which contain plugins. As I'm interested in setting up a proper dotfiles repo with GNU stow, I thought the…
detuur
  • 117
  • 1
  • 5
-1
votes
1 answer

Git subtree merge on master

I have two repo branches namely develop and master locally and in github(remotely). But with a major difference. Local master : identical to last working and stable develop branch develop : development branch Remote master : used the following…
Joey Hipolito
  • 3,108
  • 11
  • 44
  • 83
1 2 3
36
37