Re: [git-users] problem merging one repo

2015-04-06 Thread Hseu-Ming Chen
Hi Dale,
Thanks for your input.Does the approach you suggested preserves all
history of foo.git and bar.git?Sorry for not being clearer: i would
like to preserve all history of foo.git & bar.git after the merge.




On Fri, Apr 3, 2015 at 10:11 PM, Dale R. Worley  wrote:

> SoaringEagle  writes:
> > 1.  #  in the top-level directory of the cloned foo.git, add the bar repo
> > as remote_bar:
> > git remote add bar_remote 
> > git fetch bar_remote
> >
> > 2.  #  merge the bar repo into foo
> > git merge -s ours --no-commit bar_remote/master
>
> I'm no expert, but my guess is that you're telling Gig "merge everything
> between the two commits, and where they differ, choose 'ours'".  But
> since the top-level directories have different names, the two commits
> differ regarding *everything*, so you only get the 'ours' stuff.
>
> I think you could accomplish this by creating two clones, one with foo
> checked out and one with bar checked out.  Then, in foo.git, do
>
> cp -a bar.git-working-directory/* .
> git add -A
>
> Now you have all eight directories in your working directory.
>
> Construct the file tree for a new commit containing all these files:
>
> tree=$( git write-tree )
>
> Create a new commit containing these files and with both the foo and bar
> commits as parents:
>
> commit=$( git commit-tree $tree foo-HEAD bar-HEAD )
>
> Check out the new commit:
>
> git checkout $commit
>
> Dale
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Git for human beings" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/git-users/4yTs3aCCU8M/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> git-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] problem merging one repo

2015-04-06 Thread Hseu-Ming Chen
Hi Rémi,
> What you want is the behavior of git-merge(1)
, just
replace the `merge -s ours ; read-tree -m` with a single `git merge
bar_remote/master`.

Thank you for your input.   Yes, i misconstrued the git-read-tree man
page.   What you suggested appears to be working but i need to confirm with
other developers who contributed to the Scala code base for a quick sanity
check before i finalize the merge.   Anyway, much appreciated.

> ... and simply move the content from bar into foo without the history

i thought the GraphPoint approach Martin suggested does preserve all the
history or i misconstrued again

Moreover, should the
  "git remote add ..." + "git fetch ..." + "git rebase ..."
approach Magnus pointed out also preserves history.   Or you were referring
to the rebase which abandons existing commits and creates new ones (thus
non-fast-forward) ...



On Mon, Apr 6, 2015 at 4:28 PM, Rémi Rampin  wrote:

> 2015-04-03 1:51 EDT, SoaringEagle :
>
>> 3.  #  read the tree info into the index
>> git read-tree -m -u bar_remote/master
>>
>> At this time, i'm surprised to find out the top-level directory contains
>> only the 2 sub-dirs of bar.git:
>>bar1  bar2
>> and all the top-level foo[1-6] sub-dirs are gone so i can't proceed with
>> commit and push.
>>
>
> This is, in fact, the correct behavior documented in git-read-tree(1)
> 
> :
>
> If only 1 tree is specified, git read-tree operates as if the user did not
> specify -m, [...]
>
>
> What you want is the behavior of git-merge(1)
> , just
> replace the `merge -s ours ; read-tree -m` with a single `git merge
> bar_remote/master`.
>
>
> Others have described ways to not merge the branches, and simply move the
> content from bar into foo without the history, which might or might not be
> what you want (but not what you asked for).
>
> --
> Rémi
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Git for human beings" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/git-users/4yTs3aCCU8M/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> git-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] problem merging one repo

2015-04-06 Thread Rémi Rampin
2015-04-03 1:51 EDT, SoaringEagle :

> 3.  #  read the tree info into the index
> git read-tree -m -u bar_remote/master
>
> At this time, i'm surprised to find out the top-level directory contains
> only the 2 sub-dirs of bar.git:
>bar1  bar2
> and all the top-level foo[1-6] sub-dirs are gone so i can't proceed with
> commit and push.
>

This is, in fact, the correct behavior documented in git-read-tree(1)

:

If only 1 tree is specified, git read-tree operates as if the user did not
specify -m, [...]


What you want is the behavior of git-merge(1)
, just
replace the `merge -s ours ; read-tree -m` with a single `git merge
bar_remote/master`.


Others have described ways to not merge the branches, and simply move the
content from bar into foo without the history, which might or might not be
what you want (but not what you asked for).

-- 
Rémi

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] problem merging one repo

2015-04-05 Thread Magnus Therning
On Fri, Apr 03, 2015 at 08:27:47PM +0200, Martin Møller Skarbiniks Pedersen 
wrote:
> On 3 April 2015 at 15:25, Hseu-Ming Chen  wrote:
> 
> > Sorry i forgot to mention that: no, the two repos don't have any common
> > history.   In this case, how do i merge the content of bar.git into foo.git?
> >
> > Thanks.
> >
> >
> In that case, you probably want to create a fake common parent-commit using
> the so-called graft points.
> 
> See more at:
> https://git.wiki.kernel.org/index.php/GraftPoint

Graft points is one way, another is, especially if the repos aren't
too big, to just export one of the repos and import it into the other.

Or even easier, just rebase one on top of the other after adding it as
a remote:

~~~ in git folder A
% git remote add be file:///home/magnus/tmp/gitB/
git fetch be 
warning: no common commits
remote: Counting objects: 8, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 8 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (8/8), done.
>From file:///home/magnus/tmp/gitB
 * [new branch]  master -> be/master
% git lola
* cf4c7a2 (be/master) Add some text to bar2.
* e390b7b Creating folder and files for bar.
* 634f4f5 (HEAD, master) Some text in foo0.
* 8936253 Creating foo files.
% git rebase be/master 
First, rewinding head to replay your work on top of it...
Applying: Creating foo files.
Applying: Some text in foo0.
% git lola
* 9c84863 (HEAD, master) Some text in foo0.
* 6319c93 Creating foo files.
* cf4c7a2 (be/master) Add some text to bar2.
* e390b7b Creating folder and files for bar.% git lola
~~~

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

I invented the term Object-Oriented, and I can tell you I did not have
C++ in mind.
 -- Alan Kay

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


pgpohvC37oisW.pgp
Description: PGP signature


Re: [git-users] problem merging one repo

2015-04-03 Thread Dale R. Worley
SoaringEagle  writes:
> 1.  #  in the top-level directory of the cloned foo.git, add the bar repo 
> as remote_bar:
> git remote add bar_remote 
> git fetch bar_remote
>
> 2.  #  merge the bar repo into foo
> git merge -s ours --no-commit bar_remote/master

I'm no expert, but my guess is that you're telling Gig "merge everything
between the two commits, and where they differ, choose 'ours'".  But
since the top-level directories have different names, the two commits
differ regarding *everything*, so you only get the 'ours' stuff.

I think you could accomplish this by creating two clones, one with foo
checked out and one with bar checked out.  Then, in foo.git, do

cp -a bar.git-working-directory/* .
git add -A

Now you have all eight directories in your working directory.

Construct the file tree for a new commit containing all these files:

tree=$( git write-tree )

Create a new commit containing these files and with both the foo and bar
commits as parents:

commit=$( git commit-tree $tree foo-HEAD bar-HEAD )

Check out the new commit:

git checkout $commit

Dale

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] problem merging one repo

2015-04-03 Thread Martin Møller Skarbiniks Pedersen
On 3 April 2015 at 15:25, Hseu-Ming Chen  wrote:

> Sorry i forgot to mention that: no, the two repos don't have any common
> history.   In this case, how do i merge the content of bar.git into foo.git?
>
> Thanks.
>
>
In that case, you probably want to create a fake common parent-commit using
the so-called graft points.

See more at:
https://git.wiki.kernel.org/index.php/GraftPoint

Regards
Martin M. S. Pedersen

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] problem merging one repo

2015-04-03 Thread Hseu-Ming Chen
Sorry i forgot to mention that: no, the two repos don't have any common
history.   In this case, how do i merge the content of bar.git into foo.git?

Thanks.



On Fri, Apr 3, 2015 at 5:39 AM, Magnus Therning  wrote:

> On 3 Apr 2015 7:51 am, "SoaringEagle"  wrote:
> >
> > Hi,
> > i have two Git repos, foo.git and bar.git whose working trees look like:
> >
> > 
> >foo1/...
> >...
> >foo6/...
> >
> > 
> >bar1/...
> >bar2/...
> >
> > As shown above, there are 6 top-level sub-directories, namely foo1,
> foo2, ..., & foo6 in foo.git and 2 top-level sub-directories, bar1 and bar2
> in bar.git.
> >
> > i tried to merge the 2 repos together by merging the content of bar.git
> into foo.git so the new foo.git will contain all the original top-level
> sub-dirs from both foo.git and bar.git:
> >foo1  foo2  foo3  foo4  foo5  foo6  bar1  bar2
> >
> > Here is what i did:
> >
> > 1.  #  in the top-level directory of the cloned foo.git, add the bar
> repo as remote_bar:
> > git remote add bar_remote 
> > git fetch bar_remote
> >
> > 2.  #  merge the bar repo into foo
> > git merge -s ours --no-commit bar_remote/master
> >
> > 3.  #  read the tree info into the index
> > git read-tree -m -u bar_remote/master
> >
> > At this time, i'm surprised to find out the top-level directory contains
> only the 2 sub-dirs of bar.git:
> >bar1  bar2
> > and all the top-level foo[1-6] sub-dirs are gone so i can't proceed with
> commit and push.
> >
> > Where did i screw up?
>
> It's unclear from your description above whether the two repos have any
> common history. If they don't, then that might explain the behaviour you
> see.
>
> /M
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Git for human beings" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/git-users/4yTs3aCCU8M/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> git-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] problem merging one repo

2015-04-03 Thread Magnus Therning
On 3 Apr 2015 7:51 am, "SoaringEagle"  wrote:
>
> Hi,
> i have two Git repos, foo.git and bar.git whose working trees look like:
>
> 
>foo1/...
>...
>foo6/...
>
> 
>bar1/...
>bar2/...
>
> As shown above, there are 6 top-level sub-directories, namely foo1, foo2,
..., & foo6 in foo.git and 2 top-level sub-directories, bar1 and bar2 in
bar.git.
>
> i tried to merge the 2 repos together by merging the content of bar.git
into foo.git so the new foo.git will contain all the original top-level
sub-dirs from both foo.git and bar.git:
>foo1  foo2  foo3  foo4  foo5  foo6  bar1  bar2
>
> Here is what i did:
>
> 1.  #  in the top-level directory of the cloned foo.git, add the bar repo
as remote_bar:
> git remote add bar_remote 
> git fetch bar_remote
>
> 2.  #  merge the bar repo into foo
> git merge -s ours --no-commit bar_remote/master
>
> 3.  #  read the tree info into the index
> git read-tree -m -u bar_remote/master
>
> At this time, i'm surprised to find out the top-level directory contains
only the 2 sub-dirs of bar.git:
>bar1  bar2
> and all the top-level foo[1-6] sub-dirs are gone so i can't proceed with
commit and push.
>
> Where did i screw up?

It's unclear from your description above whether the two repos have any
common history. If they don't, then that might explain the behaviour you
see.

/M

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[git-users] problem merging one repo

2015-04-02 Thread SoaringEagle
Hi,
i have two Git repos, foo.git and bar.git whose working trees look like:


   foo1/...
   ...
   foo6/...
  

   bar1/...
   bar2/...

As shown above, there are 6 top-level sub-directories, namely foo1, foo2, 
..., & foo6 in foo.git and 2 top-level sub-directories, bar1 and bar2 in 
bar.git.

i tried to merge the 2 repos together by merging the content of bar.git 
into foo.git so the new foo.git will contain all the original top-level 
sub-dirs from both foo.git and bar.git:
   foo1  foo2  foo3  foo4  foo5  foo6  bar1  bar2

Here is what i did:
  
1.  #  in the top-level directory of the cloned foo.git, add the bar repo 
as remote_bar:
git remote add bar_remote 
git fetch bar_remote

2.  #  merge the bar repo into foo
git merge -s ours --no-commit bar_remote/master

3.  #  read the tree info into the index
git read-tree -m -u bar_remote/master

At this time, i'm surprised to find out the top-level directory contains 
only the 2 sub-dirs of bar.git:
   bar1  bar2
and all the top-level foo[1-6] sub-dirs are gone so i can't proceed with 
commit and push.

Where did i screw up?

Thanks for reading.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.