Additional remote on a local clone. Where do the objects go?
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.
Hi,
Quoted 10 lines · Stephen Kelly
git clone
git://gitorious.org/qt/qt.gitqtrepo 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.
Signature · 2 lines
Cheers, Ray Chuan
Quoted 14 lines · Tay Ray Chuan
Hi,
Quoted 10 lines · Stephen Kelly
git clone
git://gitorious.org/qt/qt.gitqtrepo 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 ..
Quoted 1 line
Two improvements: shared objects, and configuring git-pull:
I'm confused. I thought the local clone already used shared objects?
Quoted 9 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
Quoted 8 lines
# 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.
Quoted 9 lines
# done!
git pullRepeat for 4.7.
If you want to go one step further and track these repos, you could look at git-submodule or git-subtree.
Quoted 2 lines · Stephen Kelly
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
Signature · 3 lines
Jakub Narebski Poland ShadeHawk on #git
Hi,
(Please avoid dropping emails from the Cc list. Since you're using gmail, you could use "Reply to all".)
Quoted 4 lines · Stephen Kelly
Quoted 1 line · Tay Ray Chuan
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.)
Quoted 2 lines
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.
Quoted 5 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.
Signature · 2 lines
Cheers, Ray Chuan
Quoted 4 lines · Tay Ray Chuan
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.
Quoted 9 lines · Stephen Kelly
Quoted 4 lines
Quoted 1 line · Tay Ray Chuan
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?
Quoted 10 lines
(On hindsight, I should have used this instead of setting it up manually by writing to .git/objects/info/alternates.)
Quoted 2 lines
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.
Quoted 11 lines
Quoted 6 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.
Quoted 4 lines
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.