git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Getting Commits from One Repository to Another
@ 2009-05-20 23:37 Big Lebowski
  2009-05-21  4:04 ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: Big Lebowski @ 2009-05-20 23:37 UTC (permalink / raw)
  To: git

Hi all,

I hope this isn't a FAQ. I searched, and the closest thing in there  
(which may be what I want, but sounded wrong) was "How to share  
objects between existing repositories?" If that is it, then I  
apologize for the bandwidth.

Essentially, when I came on a project, a git repository was made  
available to me (lets call that 'public_repo'). That repository was  
put up on an unfuddle account, as an initial check-in; it was not  
cloned from the repository they were working on (lets call that  
'private_repo'). I wrote some code, and pushed it to the repository.  
Now that I guess they feel comfortable with me, they reveal to me the  
private_repo.

How do I get my code from public_repo to private_repo?

Thanks for helping a novice out.
Ryan

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

* Re: Getting Commits from One Repository to Another
  2009-05-20 23:37 Getting Commits from One Repository to Another Big Lebowski
@ 2009-05-21  4:04 ` Jeff King
  2009-05-21  9:12   ` Matthieu Moy
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff King @ 2009-05-21  4:04 UTC (permalink / raw)
  To: Big Lebowski; +Cc: git

On Wed, May 20, 2009 at 07:37:54PM -0400, Big Lebowski wrote:

> Essentially, when I came on a project, a git repository was made  
> available to me (lets call that 'public_repo'). That repository was put up 
> on an unfuddle account, as an initial check-in; it was not cloned from the 
> repository they were working on (lets call that 'private_repo'). I wrote 
> some code, and pushed it to the repository. Now that I guess they feel 
> comfortable with me, they reveal to me the private_repo.
>
> How do I get my code from public_repo to private_repo?

You could just repeat the push you made to public_repo to private_repo.
Or you could push to private_repo from public_repo, or pull from
public_repo to private_repo. One of the results of git's distributed
nature is that a commit is a commit is a commit. It doesn't matter where
it comes from: pushing or pulling the same commit (i.e., the same sha-1
commit id) will give the same results.

Does that make sense? If not, can you be more specific about the setup
(i.e., which commands were run to create public_repo and your personal
clone)? Without that, it's hard to offer more specific advice.

-Peff

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

* Re: Getting Commits from One Repository to Another
  2009-05-21  4:04 ` Jeff King
@ 2009-05-21  9:12   ` Matthieu Moy
  2009-05-21 20:08     ` Ryan
  0 siblings, 1 reply; 5+ messages in thread
From: Matthieu Moy @ 2009-05-21  9:12 UTC (permalink / raw)
  To: Jeff King; +Cc: Big Lebowski, git

Jeff King <peff@peff.net> writes:

> On Wed, May 20, 2009 at 07:37:54PM -0400, Big Lebowski wrote:
>
>> Essentially, when I came on a project, a git repository was made  
>> available to me (lets call that 'public_repo'). That repository was put up 
>> on an unfuddle account, as an initial check-in; it was not cloned from the 
>> repository they were working on (lets call that 'private_repo'). I wrote 
>> some code, and pushed it to the repository. Now that I guess they feel 
>> comfortable with me, they reveal to me the private_repo.
>>
>> How do I get my code from public_repo to private_repo?
>
> You could just repeat the push you made to public_repo to
> private_repo.

As I understand the situation, no, because the public repo was not a
clone of the private one, but a fresh import (without history?).
So, the ancestor of the commits of the OP do not exist in the private
repository.

But don't panic, "git rebase" will be able to replay your history on
another branch. The commands to type will be along the lines of:

cd public-repo
git remote add private url-of-private-repo
git fetch private
# not sure about the exact syntax here:
git rebase  --onto private/master your-first-commit^ master

and then perhaps

git push private master

-- 
Matthieu

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

* Re: Getting Commits from One Repository to Another
  2009-05-21  9:12   ` Matthieu Moy
@ 2009-05-21 20:08     ` Ryan
  2009-05-22  7:26       ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: Ryan @ 2009-05-21 20:08 UTC (permalink / raw)
  To: git

Matthieu Moy <Matthieu.Moy <at> imag.fr> writes:

> 
> Jeff King <peff <at> peff.net> writes:
> 
> > On Wed, May 20, 2009 at 07:37:54PM -0400, Big Lebowski wrote:
> >
> >> Essentially, when I came on a project, a git repository was made  
> >> available to me (lets call that 'public_repo'). That repository was put up 
> >> on an unfuddle account, as an initial check-in; it was not cloned from the 
> >> repository they were working on (lets call that 'private_repo'). I wrote 
> >> some code, and pushed it to the repository. Now that I guess they feel 
> >> comfortable with me, they reveal to me the private_repo.
> >>
> >> How do I get my code from public_repo to private_repo?
> >
> > You could just repeat the push you made to public_repo to
> > private_repo.
> 
> As I understand the situation, no, because the public repo was not a
> clone of the private one, but a fresh import (without history?).
> So, the ancestor of the commits of the OP do not exist in the private
> repository.
> 
> But don't panic, "git rebase" will be able to replay your history on
> another branch. The commands to type will be along the lines of:
> 
> cd public-repo
> git remote add private url-of-private-repo
> git fetch private
> # not sure about the exact syntax here:
> git rebase  --onto private/master your-first-commit^ master
> 
> and then perhaps
> 
> git push private master
> 

Thanks to both of you for your help. I tried Peff's suggestion last night, and
could not get it to work. Matthieu is correct that the public repo was not a
clone but a fresh import. Furthermore, I discovered that work had been done
between the last pull from private the the import into public. (Ugh!)

Anyway, before I saw Matthieu's post (away from internet, which is so rare these
days), I managed to succeed by using git format-patch on the commits that I
needed, and then used git am on the private repo. There was one conflict, but I
was able to resolve it.

Hopefully I'm not faced with this problem again, but if so, I'll try Mattieu's
suggestion.

Thanks,
Ryan

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

* Re: Getting Commits from One Repository to Another
  2009-05-21 20:08     ` Ryan
@ 2009-05-22  7:26       ` Jeff King
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff King @ 2009-05-22  7:26 UTC (permalink / raw)
  To: Ryan; +Cc: git

On Thu, May 21, 2009 at 08:08:01PM +0000, Ryan wrote:

> Thanks to both of you for your help. I tried Peff's suggestion last
> night, and could not get it to work. Matthieu is correct that the
> public repo was not a clone but a fresh import. Furthermore, I
> discovered that work had been done between the last pull from private
> the the import into public. (Ugh!)

Ah, OK, I missed that when reading your initial report. Matthieu's
suggestion is the correct one, then.

> Anyway, before I saw Matthieu's post (away from internet, which is so
> rare these days), I managed to succeed by using git format-patch on
> the commits that I needed, and then used git am on the private repo.
> There was one conflict, but I was able to resolve it.
> 
> Hopefully I'm not faced with this problem again, but if so, I'll try
> Mattieu's suggestion.

Actually, you will find that "git rebase" is basically "format-patch |
am" under the hood, so you more or less did the same thing (but calling
rebase probably would have been a little more convenient).

-Peff

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

end of thread, other threads:[~2009-05-22  7:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-20 23:37 Getting Commits from One Repository to Another Big Lebowski
2009-05-21  4:04 ` Jeff King
2009-05-21  9:12   ` Matthieu Moy
2009-05-21 20:08     ` Ryan
2009-05-22  7:26       ` Jeff King

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 NNTP newsgroup(s).