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

I have accidently push a commit which modified a git subtree. What to do now?

I have pushed a commit which modified a git subtree (not by pulling from the repository where the subtree was initially pulled). What is a clean way to restore the subtree to be what it used to be?
xuhdev
  • 8,018
  • 2
  • 41
  • 69
0
votes
0 answers

How to ignore Git subtree from parent project

I am using git subtree for my personal website, where I code in dev branch and it's build/make produces dist directory which is what I want to publish and is hence to master branch. In short: Dev: code(with dist) Master: dist(published to git…
Arpit Goyal
  • 1,017
  • 12
  • 25
0
votes
1 answer

Git subtree - subtree up-to-date but can't push for Windows

My Subtree says it's up to date, but I can't push new files git subtree pull --prefix=CASE-SENSITIVE-PATH-TO-FOLDER remote-alias master I am following Git subtree - subtree up-to-date but can't push. But need a solution that works only for windows.…
Demodave
  • 6,242
  • 6
  • 43
  • 58
0
votes
1 answer

Remote git branch checkout from within a git subtree

We've been using Heroku's review apps to help us better QA our Github issues but recently we switched from one app to two (1 backend, 1 frontend). Often times an issue in one repo will have two PRs (one from each repo) and both will be needed to…
Ryan Grush
  • 2,076
  • 3
  • 37
  • 64
0
votes
2 answers

subtrees in GIT

This is likely a simple question but I am still learning and understanding GIT... It seemed to me by testing some things, that when you add a submodule to your Git repo, you can check in your branch and along with that you are checking in that added…
jvoigt
  • 400
  • 4
  • 23
0
votes
1 answer

Is it possible to keep several git repositories under "umbrella" one?

Here is situation: # Want this folder to be "umbrella" in order not to spawn # a lot of github repos later on (you can consider it # dotfiles-like repository with a lot of remotely pulled # projects where each should be occasionally updated #…
Timur Fayzrakhmanov
  • 17,967
  • 20
  • 64
  • 95
0
votes
1 answer

Git local ignore a symlinked dir

I have two repos. They both include the same git subtree. During development, I want to symlink one subtree dir to the other. /app1 - subtree /app2 - subtree -> /app1/subtree When I run git status on app2 I get see that app2/subtree and its…
vaughan
  • 6,982
  • 6
  • 47
  • 63
0
votes
1 answer

using git-submodule without repository structure modification

I have two github repository similar to the below structure as an example: repo1: [folder_X] fileA fileB fileC fileD [folder_Y] fileE fileF repo2: [folder_M] fileB fileC fileK [folder_N] fileO fileP as you see in both repository we have some common…
A. Fasih
  • 73
  • 1
  • 10
0
votes
0 answers

Git subtree on root

I have 3 repositories: core module1 module2 And I want to do the following structure on a 4th repository: core: on the root as a git subtree on master (which includes an angular app, with some folders and "app/modules" directory on:…
Ricardo Daniel
  • 421
  • 7
  • 15
0
votes
1 answer

Handle cmake duplicated git subtrees

I have a cmake git repository with a library that I use in many project, named core. I've another cmake git repository that includes core as dependency in a subtree. This project creates a library plot. Now I have a new git repository that needs…
Jepessen
  • 11,744
  • 14
  • 82
  • 149
0
votes
1 answer

Git Submodule fatal reference is not a tree

Hi I am getting fatal: reference is not a tree: 947a3c67349eb242a8d46d576e544f8129b28cbf Unable to checkout '947a3c67349eb242a8d46d576e544f8129b28cbf' in submodule path 'modules/webform' My work station is as follows: [root]: .gitmodules …
Armando Silva
  • 181
  • 12
0
votes
0 answers

How to push all files and folders, including other git repositories?

I am using a github repository that I have modified to my purposes. This repo is now part of a bigger project, that I want to publish. The github repository and all its files shall be committed. It would also be desirable if others who pull the…
RSynch
  • 1
  • 2
0
votes
1 answer

git subtree useless merge

I added a subtree into my project demo this way $ git subtree add --prefix=plugins/plugone plugone master --squash $ tree . demo |___.git |___plugins |___plugone $ git log --oneline --all --graph --decorate * 200e94c (HEAD -> master,…
smarber
  • 4,829
  • 7
  • 37
  • 78
0
votes
1 answer

What will happen to my old pull requests if I split a subtree off my main repo and create a new repo?

I have a large codebase which I am evaluating a strategy to split certain sections off into smaller repositories. Using git subtree split, I am able to separate out the directories I want & the commit history seems intact. That being said, assuming…
Conqueror
  • 4,265
  • 7
  • 35
  • 41
0
votes
1 answer

update a subfolder that was introduced via git subtree. apply patch isn't working

I want to get 5 more changesets from the remote that I subtree'd into a subfolder and "git apply patch" isn't working, possibly because git apply treats the subtreed folder as a submodule? I got the patches via "git-format-patch". I'm working on…
timB33
  • 1,977
  • 16
  • 33