Thread (4 messages) 4 messages, 2 authors, 2016-06-15

Re: merge two local mirrors with detached heads and similar remotes

From: Zenaan Harkness <hidden>
Date: 2016-06-15 22:49:59

On Sun, Nov 7, 2010 at 13:40, Zenaan Harkness [off-list ref] wrote:
I wish to merge two local mirrors, which each should share the same
object store
...
So I want to achieve the same thing (multiple remotes in one local
repo) for an earlier clone of two separate repos, which really ought
to be just one, as follows:

A)
$ cd gitjour.git/
$ cat .git/config
[remote "origin"]
       fetch = +refs/heads/*:refs/remotes/origin/*
       url = https://github.com/chad/gitjour.git
[branch "master"]
       remote = origin
       merge = refs/heads/master
$ git branch -a
* master
 remotes/origin/HEAD -> origin/master
 remotes/origin/master

B)
$ cd gitjour-new.git/
$ cat .git/config
[remote "origin"]
       fetch = +refs/heads/*:refs/remotes/origin/*
       url = https://github.com/lachlanhardy/gitjour.git
[branch "master"]
       remote = origin
       merge = refs/heads/master
$ git branch -a
* master
 remotes/origin/8.2.0
 remotes/origin/HEAD -> origin/master
 remotes/origin/lachlanhardy
 remotes/origin/master
 remotes/origin/v8.1.0
It looks to me like I finally solved the first half of the problem,
with clarification from the following URL:
http://www.gelato.unsw.edu.au/archives/git/0601/15567.html

In A) I modified .git/config to be as follows:
$ cat .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = https://github.com/chad/gitjour.git
[branch "master"]
        remote = origin
        merge = refs/heads/master
[remote "lach"]
        url = ../u
#       fetch = +refs/heads/*:refs/remotes/origin/*
        fetch = +refs/remotes/origin/*:refs/remotes/lach/*
$ git fetch lach d
remote: Counting objects: 583, done.
remote: Compressing objects: 100% (303/303), done.
remote: Total 568 (delta 229), reused 566 (delta 229)
Receiving objects: 100% (568/568), 65.29 KiB, done.
Resolving deltas: 100% (229/229), completed with 3 local objects.
From ../u
 * [new branch]      origin/8.2.0 -> lach/8.2.0
 * [new branch]      origin/HEAD -> lach/HEAD
 * [new branch]      origin/lachlanhardy -> lach/lachlanhardy
 * [new branch]      origin/v8.1.0 -> lach/v8.1.0

# and finally:
$ git branch -a
* master
  remotes/lach/8.2.0
  remotes/lach/HEAD
  remotes/lach/lachlanhardy
  remotes/lach/master
  remotes/lach/v8.1.0
  remotes/origin/HEAD -> origin/master
  remotes/origin/master

---------
Looks very much like success to me. Small thing I notice is this line:
  remotes/origin/HEAD -> origin/master

has become this:
  remotes/lach/HEAD

(ie it's not a link any more - probably not particularly relevant,
perhaps git gc would automate tidying this?)
----------
So now I just update the remote URL for lach to point back to upstream
and I think I'm done. Happy days.

That tutorial email URL up top above might be old -
http://www.gelato.unsw.edu.au/archives/git/0601/15567.html is from
January 2006! - and is out of date a bit wrt the .git/config file
format (eg remotes wildcards), BUT in that email, Junio explained this
"local mirror" concept well enough that I could solve my problem here
(it appears) - implementing a fixup of my "local mirror" use case -
I'm a happy camper; thank you Junio!

May be I missed how to do this somewhere in the docs already, but I've
been reading and searching the web for two days, learning lots for
sure, but frustrated that it took me so long to find out how to do
this.

Should something like Junio's tutorial go into
Documentation/gitworkflows.xml(ARGGH!) ?
If not, where else?
Is there anything besides vim (about all I know) you can recommend for
editing xml(ARGGH!) docs?

Thanks
Zenaan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help