git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git subtree oddity

From
TTThomas Taranowski <tom@baringforge.com>
Date
Mar 28, 2013, 03:12 UTC
Message-ID
<CAH0ocawbOX8C7_EaNFc2PiFT8cnpSJyPD+-8RLDL1S0SX-jQvw@mail.gmail.com>
I'd like to have the following configuration:
/myproject.git
|__/upstream_dependency -- Points to a remote library git repo
|__/project_source -- local project source

I issue the following commands to pull in the upstream dependency as a subtree of the myproject.git repo:

git remote add upstream git://gnuradio.org/gnuradio git fetch upstream git checkout master git subtree add -P upstream upstream/master

Now, my expectation is that I would have the following:
/myproject.git
|__/upstream_dependency -- Points to a remote library git repo
|____< all the upstream files are present here, as expected >
|__/project_source < this is still intact, as expected >
|__< all the upstream files are present here. wtf?>

My question is, why does "subtree add" pull in all the subtree files into the root of the repo, and not just into the specified subtree prefix?

# # Here's an excerpt of what I see: # $:~/scratch/myproject.git$ ls AUTHORS gr-comedi gr-utils cmake gr-digital gr-video-sdl CMakeLists.txt gr-fcd gr-vocoder config.h.in gr-fft gr-wavelet COPYING gr-filter gr-wxgui docs gr-howto-write-a-block README dtools gr-noaa README.building-boost gnuradio-core gr-pager README.hacking gr-analog gr-qtgui README-win32-mingw-short.txt gr-atsc gr-shd upstream <---- the subtree directory gr-audio gr-trellis volk gr-blocks gruel grc gr-uh

# # Also, those same files are in the upstream subtree directory as well (as expected) # $:~/scratch/myproject.git$ ls upstream AUTHORS grc gruel cmake gr-comedi gr-uhd CMakeLists.txt gr-digital gr-utils config.h.in gr-fcd gr-video-sdl COPYING gr-fft gr-vocoder docs gr-filter gr-wavelet dtools gr-howto-write-a-block gr-wxgui gnuradio-core gr-noaa README gr-analog gr-pager README.building-boost gr-atsc gr-qtgui README.hacking gr-audio gr-shd README-win32-mingw-short.txt gr-blocks gr-trellis volk

Next: Stephen Smith
Message 1 of 7 in “git subtree oddity”
  1. Thomas TaranowskiMar 28, 2013
  2. Stephen SmithMar 28, 2013
  3. Junio C HamanoMar 28, 2013
  4. Jeremy RosenMar 28, 2013
  5. Thomas TaranowskiMar 28, 2013
  6. Thomas TaranowskiMar 28, 2013
  7. Junio C HamanoMar 29, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.