{"thread":{"id":"19426","subject":"Getting Commits from One Repository to Another","startedAt":"2009-05-20T23:37:54Z","lastAt":"2009-05-22T07:26:06Z","messageCount":5,"participants":["Big Lebowski","Jeff King","Matthieu Moy","Ryan"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"114377","messageId":"7D9240D0-C8BA-40C6-A89E-8BC7E08B1163@gmail.com","threadId":"19426","inReplyTo":null,"subject":"Getting Commits from One Repository to Another","fromName":"Big Lebowski","fromEmail":"duderino.lebowski@gmail.com","sentAt":"2009-05-20T23:37:54Z","receivedAt":"2009-05-20T23:37:54Z","isPatch":false,"sender":{"key":"duderino.lebowski@gmail.com","avatar":null},"body":"Hi all,\n\nI hope this isn't a FAQ. I searched, and the closest thing in there  \n(which may be what I want, but sounded wrong) was \"How to share  \nobjects between existing repositories?\" If that is it, then I  \napologize for the bandwidth.\n\nEssentially, when I came on a project, a git repository was made  \navailable to me (lets call that 'public_repo'). That repository was  \nput up on an unfuddle account, as an initial check-in; it was not  \ncloned from the repository they were working on (lets call that  \n'private_repo'). I wrote some code, and pushed it to the repository.  \nNow that I guess they feel comfortable with me, they reveal to me the  \nprivate_repo.\n\nHow do I get my code from public_repo to private_repo?\n\nThanks for helping a novice out.\nRyan\n"},{"id":"114388","messageId":"20090521040451.GC8091@sigill.intra.peff.net","threadId":"19426","inReplyTo":"7D9240D0-C8BA-40C6-A89E-8BC7E08B1163@gmail.com","subject":"Re: Getting Commits from One Repository to Another","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-05-21T04:04:51Z","receivedAt":"2009-05-21T04:04:51Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, May 20, 2009 at 07:37:54PM -0400, Big Lebowski wrote:\n\n> Essentially, when I came on a project, a git repository was made  \n> available to me (lets call that 'public_repo'). That repository was put up \n> on an unfuddle account, as an initial check-in; it was not cloned from the \n> repository they were working on (lets call that 'private_repo'). I wrote \n> some code, and pushed it to the repository. Now that I guess they feel \n> comfortable with me, they reveal to me the private_repo.\n>\n> How do I get my code from public_repo to private_repo?\n\nYou could just repeat the push you made to public_repo to private_repo.\nOr you could push to private_repo from public_repo, or pull from\npublic_repo to private_repo. One of the results of git's distributed\nnature is that a commit is a commit is a commit. It doesn't matter where\nit comes from: pushing or pulling the same commit (i.e., the same sha-1\ncommit id) will give the same results.\n\nDoes that make sense? If not, can you be more specific about the setup\n(i.e., which commands were run to create public_repo and your personal\nclone)? Without that, it's hard to offer more specific advice.\n\n-Peff\n"},{"id":"114399","messageId":"vpq8wkq95uu.fsf@bauges.imag.fr","threadId":"19426","inReplyTo":"20090521040451.GC8091@sigill.intra.peff.net","subject":"Re: Getting Commits from One Repository to Another","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2009-05-21T09:12:57Z","receivedAt":"2009-05-21T09:12:57Z","isPatch":false,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Wed, May 20, 2009 at 07:37:54PM -0400, Big Lebowski wrote:\n>\n>> Essentially, when I came on a project, a git repository was made  \n>> available to me (lets call that 'public_repo'). That repository was put up \n>> on an unfuddle account, as an initial check-in; it was not cloned from the \n>> repository they were working on (lets call that 'private_repo'). I wrote \n>> some code, and pushed it to the repository. Now that I guess they feel \n>> comfortable with me, they reveal to me the private_repo.\n>>\n>> How do I get my code from public_repo to private_repo?\n>\n> You could just repeat the push you made to public_repo to\n> private_repo.\n\nAs I understand the situation, no, because the public repo was not a\nclone of the private one, but a fresh import (without history?).\nSo, the ancestor of the commits of the OP do not exist in the private\nrepository.\n\nBut don't panic, \"git rebase\" will be able to replay your history on\nanother branch. The commands to type will be along the lines of:\n\ncd public-repo\ngit remote add private url-of-private-repo\ngit fetch private\n# not sure about the exact syntax here:\ngit rebase  --onto private/master your-first-commit^ master\n\nand then perhaps\n\ngit push private master\n\n-- \nMatthieu\n"},{"id":"114441","messageId":"loom.20090521T200115-589@post.gmane.org","threadId":"19426","inReplyTo":"vpq8wkq95uu.fsf@bauges.imag.fr","subject":"Re: Getting Commits from One Repository to Another","fromName":"Ryan","fromEmail":"duderino.lebowski@gmail.com","sentAt":"2009-05-21T20:08:01Z","receivedAt":"2009-05-21T20:08:01Z","isPatch":false,"sender":{"key":"duderino.lebowski@gmail.com","avatar":null},"body":"Matthieu Moy <Matthieu.Moy <at> imag.fr> writes:\n\n> \n> Jeff King <peff <at> peff.net> writes:\n> \n> > On Wed, May 20, 2009 at 07:37:54PM -0400, Big Lebowski wrote:\n> >\n> >> Essentially, when I came on a project, a git repository was made  \n> >> available to me (lets call that 'public_repo'). That repository was put up \n> >> on an unfuddle account, as an initial check-in; it was not cloned from the \n> >> repository they were working on (lets call that 'private_repo'). I wrote \n> >> some code, and pushed it to the repository. Now that I guess they feel \n> >> comfortable with me, they reveal to me the private_repo.\n> >>\n> >> How do I get my code from public_repo to private_repo?\n> >\n> > You could just repeat the push you made to public_repo to\n> > private_repo.\n> \n> As I understand the situation, no, because the public repo was not a\n> clone of the private one, but a fresh import (without history?).\n> So, the ancestor of the commits of the OP do not exist in the private\n> repository.\n> \n> But don't panic, \"git rebase\" will be able to replay your history on\n> another branch. The commands to type will be along the lines of:\n> \n> cd public-repo\n> git remote add private url-of-private-repo\n> git fetch private\n> # not sure about the exact syntax here:\n> git rebase  --onto private/master your-first-commit^ master\n> \n> and then perhaps\n> \n> git push private master\n> \n\nThanks to both of you for your help. I tried Peff's suggestion last night, and\ncould not get it to work. Matthieu is correct that the public repo was not a\nclone but a fresh import. Furthermore, I discovered that work had been done\nbetween the last pull from private the the import into public. (Ugh!)\n\nAnyway, before I saw Matthieu's post (away from internet, which is so rare these\ndays), I managed to succeed by using git format-patch on the commits that I\nneeded, and then used git am on the private repo. There was one conflict, but I\nwas able to resolve it.\n\nHopefully I'm not faced with this problem again, but if so, I'll try Mattieu's\nsuggestion.\n\nThanks,\nRyan\n"},{"id":"114451","messageId":"20090522072606.GA1409@coredump.intra.peff.net","threadId":"19426","inReplyTo":"loom.20090521T200115-589@post.gmane.org","subject":"Re: Getting Commits from One Repository to Another","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-05-22T07:26:06Z","receivedAt":"2009-05-22T07:26:06Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, May 21, 2009 at 08:08:01PM +0000, Ryan wrote:\n\n> Thanks to both of you for your help. I tried Peff's suggestion last\n> night, and could not get it to work. Matthieu is correct that the\n> public repo was not a clone but a fresh import. Furthermore, I\n> discovered that work had been done between the last pull from private\n> the the import into public. (Ugh!)\n\nAh, OK, I missed that when reading your initial report. Matthieu's\nsuggestion is the correct one, then.\n\n> Anyway, before I saw Matthieu's post (away from internet, which is so\n> rare these days), I managed to succeed by using git format-patch on\n> the commits that I needed, and then used git am on the private repo.\n> There was one conflict, but I was able to resolve it.\n> \n> Hopefully I'm not faced with this problem again, but if so, I'll try\n> Mattieu's suggestion.\n\nActually, you will find that \"git rebase\" is basically \"format-patch |\nam\" under the hood, so you more or less did the same thing (but calling\nrebase probably would have been a little more convenient).\n\n-Peff\n"}]}