git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* Merging/joining two repos (repo2 should be a subdirectory of repo1)
@ 2012-09-30 15:17 Dirk Süsserott
       [not found] ` <1349018675-ner-5178@calvin>
       [not found] ` <269806202.iK1l2OpKr4@blacky>
  0 siblings, 2 replies; 5+ messages in thread
From: Dirk Süsserott @ 2012-09-30 15:17 UTC (permalink / raw)
  To: Git Mailing List

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?

Thanks in advance
Dirk

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Merging/joining two repos (repo2 should be a subdirectory of repo1)
       [not found] ` <1349018675-ner-5178@calvin>
@ 2012-09-30 15:32   ` Dirk Süsserott
  2012-09-30 20:44     ` David Aguilar
  0 siblings, 1 reply; 5+ messages in thread
From: Dirk Süsserott @ 2012-09-30 15:32 UTC (permalink / raw)
  To: Tomas Carnecky; +Cc: Git Mailing List

Am 30.09.2012 17:24 schrieb Tomas Carnecky:
> 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! :-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Merging/joining two repos (repo2 should be a subdirectory of repo1)
       [not found] ` <269806202.iK1l2OpKr4@blacky>
@ 2012-09-30 15:38   ` Dirk Süsserott
  0 siblings, 0 replies; 5+ messages in thread
From: Dirk Süsserott @ 2012-09-30 15:38 UTC (permalink / raw)
  To: Sascha Cunz; +Cc: Git Mailing List

Am 30.09.2012 17:34 schrieb Sascha Cunz:
>
> You might want to have a look at the subtree merge strategy (see man
> git-merge). Maybe that will already do what you want to.
> 
>  
> 
> Sascha
> 

Thank you as well. I wasn't aware of that option (or didn't figure out
what it actually does).

Dirk

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Merging/joining two repos (repo2 should be a subdirectory of repo1)
  2012-09-30 15:32   ` Dirk Süsserott
@ 2012-09-30 20:44     ` David Aguilar
  2012-10-03 12:52       ` Dirk Süsserott
  0 siblings, 1 reply; 5+ messages in thread
From: David Aguilar @ 2012-09-30 20:44 UTC (permalink / raw)
  To: Dirk Süsserott; +Cc: Tomas Carnecky, Git Mailing List

On Sun, Sep 30, 2012 at 8:32 AM, Dirk Süsserott <newsletter@dirk.my1.cc> wrote:
> Am 30.09.2012 17:24 schrieb Tomas Carnecky:
>> 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! :-)

Hi Dirk,

You should also take a look at contrib/subtree/ in the git source tree.

"git subtree" does pretty much exactly what you're looking to do,
and it is a bit more user-friendly than the plumbing commands.

https://github.com/git/git/blob/master/contrib/subtree/git-subtree.txt
-- 
David

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Merging/joining two repos (repo2 should be a subdirectory of repo1)
  2012-09-30 20:44     ` David Aguilar
@ 2012-10-03 12:52       ` Dirk Süsserott
  0 siblings, 0 replies; 5+ messages in thread
From: Dirk Süsserott @ 2012-10-03 12:52 UTC (permalink / raw)
  To: David Aguilar; +Cc: Tomas Carnecky, Git Mailing List

Am 30.09.2012 22:44 schrieb David Aguilar:
> On Sun, Sep 30, 2012 at 8:32 AM, Dirk Süsserott <newsletter@dirk.my1.cc> wrote:
>> Am 30.09.2012 17:24 schrieb Tomas Carnecky:
>>> 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! :-)
> 
> Hi Dirk,
> 
> You should also take a look at contrib/subtree/ in the git source tree.
> 
> "git subtree" does pretty much exactly what you're looking to do,
> and it is a bit more user-friendly than the plumbing commands.
> 
> https://github.com/git/git/blob/master/contrib/subtree/git-subtree.txt
> 

Hi David,

thanks for the pointer. I know of subtree and like it. But for my case
I'll stick to the plumbing commands because I really want to *import*
$repo2 into $repo1 and then delete $repo2. One shot.

(Actually I re-wrote a part of our project just for fun and didn't do it
in the main project's repo in a separate branch (as I normally do) but
in a totaly separate repo. And now it turned out that my rewritten part
is really cool and we want to include it in the main $repo1 and drop my
private $repo2.)

Dirk

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-10-03 12:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-30 15:17 Merging/joining two repos (repo2 should be a subdirectory of repo1) Dirk Süsserott
     [not found] ` <1349018675-ner-5178@calvin>
2012-09-30 15:32   ` Dirk Süsserott
2012-09-30 20:44     ` David Aguilar
2012-10-03 12:52       ` Dirk Süsserott
     [not found] ` <269806202.iK1l2OpKr4@blacky>
2012-09-30 15:38   ` Dirk Süsserott

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).