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

Re: Merging/joining two repos (repo2 should be a subdirectory of repo1)

From
DSDirk Süsserott <newsletter@dirk.my1.cc>
Date
Sep 30, 2012, 15:32 UTC
Message-ID
<50686605.6020909@dirk.my1.cc>
In-Reply-To
<1349018675-ner-5178@calvin>
Am 30.09.2012 17:24 schrieb Tomas Carnecky:
Show 26 quoted lines
> On Sun, 30 Sep 2012 17:17:53 +0200, Dirk SÃŒsserott <newsletter@dirk.my1.cc> wrote:
>> Hi!
>>
>> I have repo1 with ~4 years of history and another repo2 with ~1 year of
>> history, both of which I don't want to loose. Now I want to join them so
>> that repo2 becomes a subdirectory whithin repo1, including all the
>> history of repo2.
>>
>> A simple git-merge won't do because both repos have some same files (at
>> least e.g. .gitignore) in their root directories. Of course I could
>> resolve the conflicts, but I don't want that.
>>
>> My naive approach is "move everything in $repo2 one directory below" and
>> then "merge $repo2 into $repo1". Actually I wouldn' call that a "merge"
>> but an "import".
>>
>> I know of "git filter-branch --subdirectory-filter foodir" but that's
>> just the opposite of what I need.
>>
>> Is there a nifty trick to get this? Or will I have to do "git
>> filter-branch --tree-filter 'mkdir subdir && git mv * subdir' --all" on
>> $repo2 and then "git merge $repo2" in $repo1?
> 
> http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html
> 
> 
Wow! Thanks for that quick and *very* helpful answer! :-)
Previous: Dirk SüsserottNext: David Aguilar
Message 2 of 5 in “Merging/joining two repos (repo2 should be a subdirectory of repo1)”
  1. Dirk SüsserottSep 30, 2012
  2. Dirk SüsserottSep 30, 2012
  3. David AguilarSep 30, 2012
  4. Dirk SüsserottOct 3, 2012
  5. Dirk SüsserottSep 30, 2012

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.