threads / discuss / 31483

Keeping two repos in sync

Subject: Keeping two repos in sync

## tl;dr

4 messages between Sep 9, 2012 and Sep 9, 2012.

replies: 3people: 2as markdown or json

David Chanters· Sep 9, 2012, 08:12 UTC · lore
Hi all,
I'm wondering how best to go about this problem.  I've got two
separate git repositories -- one is a portable version which I'll call
"portable", the other is part of a BSD project, which I'll call "bsd".
 Both repositories have the same set of *conceptual* files in them,
it's just that the portable repository has additional files which are
not found in the bsd repository.  It should be noted that the bsd
repository is an automatically managed cvsexport clone of a CVS
repository -- but I don't think this matters here, as we're just
talking about two git repositories.

The "workflow" if you can call it that, is commits happen in the bsd repository and are then put in the portable repo. At the moment, I am using git grafts to do this. The important point to remember here is the two repositories DO NOT have any common history to them -- it's just that where the files are the same in both the bsd and portable repository I can see and hence tell git, where to graft the two master branches from each repository and for me to merge bsd:master -> portable:master.

However, I am wondering how best to handle this situation. It's pretty convoluted -- not to mention the fact that git grafts are never permanent. What I'd like is for some "safe" way of setting up an initial git graft which tied the two master branches between bsd and portable to reflect changes on bsd:master not on portable:master and then for me to treat those two branches as though they shared common history so that I can merge one to the other. Unfortunately, what I'm doing at the moment is each time changes happen to bsd:master, I'm having to reset the git graft each time; and since that operation is a local one, it makes things rather awkward in a shared repository situation as I am the sole person who can perform these merges.

I'm guessing I could rebase at some point and push those changes out? I'm just wondering how other people handle this situation or if it's just unique to me?

Kindly,
David
Andreas Schwab· Sep 9, 2012, 08:36 UTC · re: David Chanters · lore

Re: Keeping two repos in sync

Add "bsd" as a remote in "portable" and cherry-pick each commit in "bsd".

Andreas.
-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
David Chanters· Sep 9, 2012, 08:44 UTC · re: Andreas Schwab · lore

Re: Keeping two repos in sync

Hi,
On 9 September 2012 09:36, Andreas Schwab <schwab@linux-m68k.org> wrote:
> Add "bsd" as a remote in "portable" and cherry-pick each commit in
> "bsd".
I am already kind of doing this at the moment.  Hence:
1.  In portable, I have:

% git remote add bsd /path/to/bsd/repo % git fetch bsd

2.  At this point I scan the two branches looking for a point to
graft; I might have done this already in the past, but the point is
since grafting is a local operation and I am not working in that
repository, I might need to do it again anyway -- that graft
represents a way of tieing the branches together at a point I can then
"git merge".
Kindly,
David
Andreas Schwab· Sep 9, 2012, 09:03 UTC · re: David Chanters · lore

Re: Keeping two repos in sync

David Chanters <david.chanters@googlemail.com> writes:
Show 6 quoted lines
> 2.  At this point I scan the two branches looking for a point to
> graft; I might have done this already in the past, but the point is
> since grafting is a local operation and I am not working in that
> repository, I might need to do it again anyway -- that graft
> represents a way of tieing the branches together at a point I can then
> "git merge".

You can "git merge -s ours" that grafting point, assuming "portable" completely subsumes "bsd" at that point. Future merges should then be working normally.

Andreas.
-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

← back to recent threads