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

Reduce git subtree commit log noise

I use Yeoman for deployment of my web app. As per the suggestion of the Yeoman docs, I deploy my site using git subtree, doing something like this: grunt build git add -A dist git commit -m "New release" git subtree push --prefix dist origin…
cdmckay
  • 31,832
  • 25
  • 83
  • 114
0
votes
1 answer

Cant see new repository after git subtree split

I have a project which uses a few self made "modules". I want to put these modules in separate (read only) repositories. I tried to do this with the subtree split command. But I don't see my new branched repository anywhere. I first ran this…
Vivendi
  • 20,047
  • 25
  • 121
  • 196
0
votes
2 answers

Splitting multi-facet C# project using GIT

We recently made the switch from SVN to GIT for our repo management, and have a good grasp on the non-linear source control style. At the moment, the entire codebase (Mixture of Services, Windows/Xamarin clients and ASP.net website) was dumped into…
Daniel Park
  • 3,903
  • 4
  • 23
  • 38
0
votes
1 answer

git split repo but have same commit-ids

I have a big git repo and I want to split that into 2. I am able to do this using "git filter-branch" or "git subtree split" but both methods are creating completely new commits-ids (SHAs). I know we are rewriting history and it will change…
Sridhar
  • 803
  • 1
  • 12
  • 21
0
votes
1 answer

How to use a git sub repository pushing to a private remote but pulling also from its original origin

I need to setup a repository like this: rep (pull & push from/to private remote) normal stuff sub-rep (pull from private remote & public remote and push to private remote) stuff in sub-rep sub-module (pull from private remote & public remote and…
JD3
  • 33
  • 1
  • 7
0
votes
1 answer

Using git subtree for asset swapping

I'm working on an Android project which has several skins/graphics packs. I have created several folders of assets which are named identically, but are different graphics (for different brands). Initially I thought that I could create a main project…
user1654794
  • 225
  • 4
  • 10
0
votes
1 answer

Splitting out a sub directory in a git repo into it's own repo

I have the following structure: my_main_project/ my_lib/ file1 dir2/ file2 my_other_files And now, the my_lib has got to the point where it really should be it's own library, and should be a submodule in…
111111
  • 15,686
  • 6
  • 47
  • 62
0
votes
1 answer

Publish a sub tree to a different GIT repository

I know there are sub trees and sub modules within GIT but i am still not sure which one would be the best option in my case. So the situation is this: I have a project with "lib1" and "lib2", project and repo are already there, i am not starting…
JohnUopini
  • 960
  • 9
  • 24
0
votes
1 answer

How to merge subtree changes upstream

I'm following the subtree walk-through from here. I'm at the point where I want to merge local changes I've made in my subtree upstream to the original repository, but the walk-through doesn't specify what command should be run. To merge into my…
Joe Enzminger
  • 11,110
  • 3
  • 50
  • 75
0
votes
1 answer

How to perform a subtree merge using plumbing commands?

I want to combine a subtree merge into a regular (non-merge) commit. I currently do this by first performing the subtree merge, then amending this with the regular changes. git merge --strategy subtree --strategy-option subtree=subdir…
Brecht Machiels
  • 3,181
  • 3
  • 25
  • 38
0
votes
0 answers

multiple git subtrees from multiple repos, offsetting the directory layout

say I have 2 different git repos: repo-1: /dir11 /dir12 /dir13 repo-2: /dir21 /dir22 /dir23 so far I only managed the following (with sparsecheckout): work-repo: /repo-1 /dir11 /repo-2 /dir22 /dir23 But I'd really like to be…
sbinet
  • 16
  • 1
0
votes
1 answer

Create new repository out of git subtree

When using git subtree an entire new tree, including a new first commit, is created in the same repository in which it was created. This means that at that point the repository contains two completely independent trees inside it, with no common…
Maic López Sáenz
  • 10,385
  • 4
  • 44
  • 57
0
votes
1 answer

Side-by-side recursive Git submodules

In our company we make projects by piling-up several frameworks / libraries: /Framework /Extensions (depends on Framework) /Business (depends on Framework & Extensions) /Project A (depends on Framework & Extensions & Business) /Project B (depends…
Olmo
  • 4,257
  • 3
  • 31
  • 35
0
votes
1 answer

Git subtree error

I tried to install git-subtree on Mac and after the first step: cp git-subtree.sh "$(git --exec-path)"/git-subtree when I try to use git-subtree I get always an error: sudo git subtree split -P ObjectiveBlip export fatal: cannot exec…
Mihai Panţiru
  • 513
  • 3
  • 16
-1
votes
0 answers

How to merge 2 git repositories into a single one with interleaved chronological commits

I have two git repositories: main and package_1. I want to merge package_1 into main and put it inside a folder, say package_1. By doing this I am ok rewriting the history of main so that I achieve interleaved commits from the two repositories, of…
Vitor
  • 151
  • 6
1 2 3
36
37