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
0
votes
1 answer

Sharing the same repository between two projects using SourceTree

I'm trying to find out if it's possible to share the same repository between two projects with Git/SourceTree. I have a two sites with their own repos, both have a plugins folder. Currently, any changes I apply to one plugin, i have to do the same…
david-l
  • 623
  • 1
  • 9
  • 20
0
votes
1 answer

Git subtree that is dependent on the parent directory, or fork that only pushes some subfolders upstream

What I want to do in my project is fork an existing "framework" repository i've developed, and create a subfolder within the forked repo to store project-specific files (think "engine" and "game"). I want to retain the ability to make changes to…
Roger Levy
  • 105
  • 1
  • 1
  • 9
0
votes
2 answers

Convert Git subtree to submodule

I'm convinced that git subtrees are not the right fit for my project and I'd like to convert my git subtree structure to a git submodule. How can I do this? With a structure: main-repo │ index.js │ package.json │ └───vendor …
DiverseAndRemote.com
  • 19,314
  • 10
  • 61
  • 70
0
votes
1 answer

Include other branch as subdirectory?

I'm trying to set up a branch such that branchA has subfolders A and B, but B contains the contents of branchB. I've been looking at submodules, subtrees, and subrepos, but I can't figure out what would do what I am looking for. In order to prevent…
Dessa Simpson
  • 1,232
  • 1
  • 15
  • 30
0
votes
1 answer

How to create a git release branch from a directory that is not checked in remote master

I am wondering how to achieve my goal, I want to create a new branch from the master directory, but the directory is autogenerated and it is not checked in. I want my release branch contains only the final binaries. Thiis the tree of my master: $…
danglingpointer
  • 4,708
  • 3
  • 24
  • 42
0
votes
1 answer

cannot update github pages with subtree push

I'm having trouble pushing to my gh-pages branch. I have an organization account, with both server and client code in it (though I think this should not really matter). So the structure is like so: my-org my-repo client src …
Hoff
  • 38,776
  • 17
  • 74
  • 99
0
votes
2 answers

Segment git project into submodules

I have a git project that is currently growing and several parts are starting to become projects in their own right. So, I want to create submodules for them, but preserve the history of the files. There were moves between the different folders (eG…
Angelo Fuchs
  • 9,825
  • 1
  • 35
  • 72
0
votes
1 answer

Git Subtree Merge - Merge all branches in subtree repo into parent repo at same time

Is it possible, using a Git Subtree Merge, to merge all branches of Repo B into Repo A at the same time, with one Git Command? Repo B has close to 15 different branches and I'm trying to save time by doing a sub merge of the repo and all of its…
bschmitty
  • 1,118
  • 3
  • 16
  • 46
0
votes
0 answers

Sharing header & footer between repos

The Problem: Sharing a header and footer between two repos that use different technologies - one is Rails and the other is PHP. They are on different subdomains. Current Implementation: Up until this point we have just been copying and pasting the…
dipole_moment
  • 5,266
  • 4
  • 39
  • 55
0
votes
1 answer

How to deploy only part of project to Heroku?

I am building a project that consists of two folders: one to be run on an IOT device and the other to run on the server. The server part is to be deployed on Heroku. I'd like to keep the project in one overall Git project though, so that I can keep…
Aron
  • 8,696
  • 6
  • 33
  • 59
0
votes
0 answers

how to use git repos inside another git project without Gitsubmodule or subtree

I have two git repositories main-pro and another git repo plugins I use main-pro as my core and plugin to components. I don't want to use the git-submodule anymore because every change in the plugin repo will show in the main-pro's change list. I…
coderex
  • 27,225
  • 45
  • 116
  • 170
0
votes
1 answer

Readd Git subtree

I added a git subtree to one of my projects recently, but due to a slew of git errors would like to "delete" and readd this subtree. Is there any way I can remove the subtree, and readd it? When manually removing it with the 'rm' command and…
Jeff Gong
  • 1,713
  • 3
  • 15
  • 19
0
votes
2 answers

Version a "starter kit" to work upon in other projects

All my projects have the same structure, base files (each containing some code). Things I would like : Version this code ; Use it in other projects ; Be able to update it in those projects ; Only add code in those files, specific to each project…
0
votes
1 answer

Including Class Library from SVN (Local) in a project hosted in Git (BitBucket)

I have a simple class library that currently resides within SVN hosted locally. I'm working on an MVC project that resides within GIT hosted through bitbucket. The class library is a wrapper to a production web service that I need to reference in…
mckennawebdev
  • 547
  • 1
  • 5
  • 17
0
votes
1 answer

Squash on default when using git subtree

I'm often running git subtree pull -P shared shared master but I usually forget to put --squash at the end which ends up duplicating most of my git history. Is it possible to make git use that by default? Thanks!
Ingo
  • 802
  • 9
  • 21