threads / discuss / 24931

Additional remote on a local clone. Where do the objects go?

Subject: Additional remote on a local clone. Where do the objects go?

## tl;dr

6 messages between Sep 1, 2010 and Sep 5, 2010.

replies: 5people: 3as markdown or json

Stephen Kelly· Sep 1, 2010, 07:12 UTC · lore
Hi,
I have done something like this :

git clone git://gitorious.org/qt/qt.git qtrepo cd qtrepo git checkout -b 4.7 origin/4.7 git checkout -b 4.6 origin/4.6 git clone qtrepo qt46 cd qt46 && git checkout -b 4.6 origin/4.6 cd .. git clone qtrepo qt47 cd qt46 && git checkout -b 4.7 origin/4.7 cd ..

The aim is to have multiple local checkouts of different branches of Qt while sharing the same object store. However, it is inconvenient to have to pull in the qtrepo directory, then cd to the other two to get the changes.

It would be more convenient to be able to add the qt.git remote to the local clones, pull from it, and have the pulled objects shared in the same object store. Is that possible or is it what already happens? I will also want to add additional remotes for pushing changes to from the local clones.

All the best,
Steve.
Tay Ray Chuan· Sep 1, 2010, 10:32 UTC · re: Stephen Kelly · lore

Re: Additional remote on a local clone. Where do the objects go?

Hi,
On Wed, Sep 1, 2010 at 3:12 PM, Stephen Kelly <steveire@gmail.com> wrote:
Show 10 quoted lines
> git clone git://gitorious.org/qt/qt.git qtrepo
> cd qtrepo
> git checkout -b 4.7 origin/4.7
> git checkout -b 4.6 origin/4.6
> git clone qtrepo qt46
> cd qt46 && git checkout -b 4.6 origin/4.6
> cd ..
> git clone qtrepo qt47
> cd qt46 && git checkout -b 4.7 origin/4.7
> cd ..
Two improvements: shared objects, and configuring git-pull:
  git clone git://gitorious.org/qt/qt.git qtrepo
  git init qt46
  PARENT_GIT=$(pwd)/qtrepo/.git
  cd qt46
  # use of shared objects - tell git where to find the "missing" objects
  cat $PARENT_GIT/objects > .git/objects/info/alternates
  # setup of git pull
  cat <<EOF >> .git/config
[remote "parent"]
  url = $PARENT_GIT
[branch "master"]
  remote = parent
  merge = refs/remotes/origin/4.6
EOF
  # done!
  git pull
Repeat for 4.7.

If you want to go one step further and track these repos, you could look at git-submodule or git-subtree.

-- 
Cheers,
Ray Chuan
Stephen Kelly· Sep 1, 2010, 11:51 UTC · re: Tay Ray Chuan · lore

Re: Additional remote on a local clone. Where do the objects go?

Tay Ray Chuan wrote:
Show 15 quoted lines
> Hi,
> 
> On Wed, Sep 1, 2010 at 3:12 PM, Stephen Kelly <steveire@gmail.com> wrote:
>> git clone git://gitorious.org/qt/qt.git qtrepo
>> cd qtrepo
>> git checkout -b 4.7 origin/4.7
>> git checkout -b 4.6 origin/4.6
>> git clone qtrepo qt46
>> cd qt46 && git checkout -b 4.6 origin/4.6
>> cd ..
>> git clone qtrepo qt47
>> cd qt46 && git checkout -b 4.7 origin/4.7
>> cd ..
> 
> Two improvements: shared objects, and configuring git-pull:
I'm confused. I thought the local clone already used shared objects?
Show 17 quoted lines
> 
>   git clone git://gitorious.org/qt/qt.git qtrepo
>   git init qt46
>   PARENT_GIT=$(pwd)/qtrepo/.git
>   cd qt46
> 
>   # use of shared objects - tell git where to find the "missing" objects
>   cat $PARENT_GIT/objects > .git/objects/info/alternates
> 
>   # setup of git pull
>   cat <<EOF >> .git/config
> [remote "parent"]
>   url = $PARENT_GIT
> [branch "master"]
>   remote = parent
>   merge = refs/remotes/origin/4.6
> EOF

So this will pull from the gitorious remote and store the objects in the parent git from where they are shared with this local clone?

Which is the better solution between this and git-new-workdir given that these are permanent branches, not temporary, and I'll want to push and pull various clones and share the objects. It looks like the git-new-workdir option creates symlinks, whereas the local clone creates hard links, and this solution creates a redirect of sorts.

Show 9 quoted lines
> 
>   # done!
>   git pull
> 
> Repeat for 4.7.
> 
> If you want to go one step further and track these repos, you could
> look at git-submodule or git-subtree.
> 
Tay Ray Chuan· Sep 4, 2010, 14:15 UTC · re: Stephen Kelly · lore

Re: Additional remote on a local clone. Where do the objects go?

Hi,

(Please avoid dropping emails from the Cc list. Since you're using gmail, you could use "Reply to all".)

On Wed, Sep 1, 2010 at 7:51 PM, Stephen Kelly <steveire@gmail.com> wrote:
> Tay Ray Chuan wrote:
>> Two improvements: shared objects, and configuring git-pull:
>
> I'm confused. I thought the local clone already used shared objects?

You'd have to use "-s/--shared" with git clone; I don't think it's done by default.

(On hindsight, I should have used this instead of setting it up manually by writing to .git/objects/info/alternates.)

> So this will pull from the gitorious remote and store the objects in the
> parent git from where they are shared with this local clone?

No, you'd have to first pull from gitorious in your parent directory, before going into the local repo/branch (eg. qt46) and then pulling again.

Show 5 quoted lines
> Which is the better solution between this and git-new-workdir given that
> these are permanent branches, not temporary, and I'll want to push and pull
> various clones and share the objects. It looks like the git-new-workdir
> option creates symlinks, whereas the local clone creates hard links, and
> this solution creates a redirect of sorts.

I haven't used git-new-workdir comprehensively, so I'll avoid commenting too much, but I'd like to know if you've looked at branches? You can just switch between each and do your qt 4.6- and 4.7-specific work.

I say that, because what you're doing sounds like what a hg user would do to emulate git branches.

-- 
Cheers,
Ray Chuan
Stephen Kelly· Sep 5, 2010, 23:50 UTC · re: Tay Ray Chuan · lore

Re: Additional remote on a local clone. Where do the objects go?

Tay Ray Chuan wrote:
> Hi,
> 
> (Please avoid dropping emails from the Cc list. Since you're using
> gmail, you could use "Reply to all".)

Actually I'm posting using GMane through KNode. I'll keep you in the CC but there's no need to CC me.

Show 9 quoted lines
> 
> On Wed, Sep 1, 2010 at 7:51 PM, Stephen Kelly <steveire@gmail.com> wrote:
>> Tay Ray Chuan wrote:
>>> Two improvements: shared objects, and configuring git-pull:
>>
>> I'm confused. I thought the local clone already used shared objects?
> 
> You'd have to use "-s/--shared" with git clone; I don't think it's
> done by default.

Indeed, --local is default, which sets up hard links, so they are shared in that sense. So it looks like the suggestion is I should remove the --local clones and start again with --shared so that the objects directory is symlinked? Is that better than hard links?

Show 10 quoted lines
> 
> (On hindsight, I should have used this instead of setting it up
> manually by writing to .git/objects/info/alternates.)
> 
>> So this will pull from the gitorious remote and store the objects in the
>> parent git from where they are shared with this local clone?
> 
> No, you'd have to first pull from gitorious in your parent directory,
> before going into the local repo/branch (eg. qt46) and then pulling
> again.

Right. That's what I do currently, but it's not optimally convenient. I'd like to just go to the qt46 clone, set it up with the correct remote url and pull there, with the result being that the objects I pull are still shared across all the local clones.

Show 11 quoted lines
> 
>> Which is the better solution between this and git-new-workdir given that
>> these are permanent branches, not temporary, and I'll want to push and
>> pull various clones and share the objects. It looks like the
>> git-new-workdir option creates symlinks, whereas the local clone creates
>> hard links, and this solution creates a redirect of sorts.
> 
> I haven't used git-new-workdir comprehensively, so I'll avoid
> commenting too much, but I'd like to know if you've looked at
> branches? You can just switch between each and do your qt 4.6- and
> 4.7-specific work.

Switching between branches costs time and I often need to work with more than one at a time, and I need separate build directories for them, so I'm trying to get these 'permanent checked-out branch directories' set up conveniently.

> 
> I say that, because what you're doing sounds like what a hg user would
> do to emulate git branches.
> 

I only used hg for the first time on Friday to clone a repo. Not sure what the workflow with that SCM is.

Thanks for the pointers,
Steve.
Jakub Narebski· Sep 1, 2010, 10:34 UTC · re: Stephen Kelly · lore

Re: Additional remote on a local clone. Where do the objects go?

Stephen Kelly <steveire@gmail.com> writes:
> The aim is to have multiple local checkouts of different branches of Qt 
> while sharing the same object store. [...]

Why not use git-new-workdir shell script from contrib/worktree/ in git sources[1]?

[1] http://repo.or.cz/w/git.git/blob_plain/HEAD:/contrib/workdir/git-new-workdir
-- 
Jakub Narebski
Poland
ShadeHawk on #git

← back to recent threads