* can I use multiple worktree in same git repo ?
@ 2011-07-20 12:54 J. Bakshi
2011-07-20 13:25 ` Nguyen Thai Ngoc Duy
0 siblings, 1 reply; 9+ messages in thread
From: J. Bakshi @ 2011-07-20 12:54 UTC (permalink / raw)
To: git@vger.kernel.org
Hello list,
Please bear with me as I am from svn domain and gradually making myself aware of git.
I have a site under htdocs which is modified by svn with the help of post-commit hook. But the svn folder structure is little different than the actual structure at filesystem.
Under htdocs/demo, say I have dir1, dir2 etc... where in svn I have the structure as
[svn]
mysite-repo
|
|----------dir1------|trunk----src (here actually I have the contents of dir1)
|----------|---------|tags
|----------|---------|branches
|
|----------dir2------|trunk----src (here actually I have the contents of dir2)
|----------|---------|tags
|----------|---------|branches
And in file-system dir1 is mapped with (checkout from) and then (svn switch --relocate) mysite-repo/dir1/trunk/src ;
dir2 is checkout from and then (svn switch --relocate) mysite-repo/dir2/trunk/src
and so on .....
Now the post-commit hook is tricky.
```````
#!/bin/bash
set -e
# LANG=en_US.UTF-8 for special character support
LANG=en_US.UTF-8 /usr/bin/svn up /var/www/demo/dir1
LANG=en_US.UTF-8 /usr/bin/svn up /var/www/demo/dir2
LANG=en_US.UTF-8 /usr/bin/svn up /var/www/demo/dir3
````````````````
As a result whenever there is a commit , it updates the related folder in filesystem.
Say a commit at svn->mysite-repo->dir1->trunk->src ==> modify ==> /var/www/demo/dir1
Can I do the same in git with multiple worktree ? possible ?
Thanks
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: can I use multiple worktree in same git repo ?
2011-07-20 12:54 can I use multiple worktree in same git repo ? J. Bakshi
@ 2011-07-20 13:25 ` Nguyen Thai Ngoc Duy
2011-07-20 16:12 ` J. Bakshi
2011-07-21 18:17 ` Jakub Narebski
0 siblings, 2 replies; 9+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2011-07-20 13:25 UTC (permalink / raw)
To: J. Bakshi; +Cc: git@vger.kernel.org
On Wed, Jul 20, 2011 at 7:54 PM, J. Bakshi <joydeep@infoservices.in> wrote:
> As a result whenever there is a commit , it updates the related folder in filesystem.
> Say a commit at svn->mysite-repo->dir1->trunk->src ==> modify ==> /var/www/demo/dir1
>
> Can I do the same in git with multiple worktree ? possible ?
Using multiple worktree with the same repo won't work in git because
the repo also have worktree-related information. But you can create a
central, bare repository, then make several clones from that. Each one
is checked out with different branches. You work on a clone and push
to the central repo. The post-commit hook in the central repo will do
pull from it, for example
for site in dir1 dir2 dir3; do
cd /var/www/$site && /usr/bin/git pull
done
Also have a look at git-new-workdir in contrib directory of git
repository. I don't use it but you might find it useful.
--
Duy
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: can I use multiple worktree in same git repo ?
2011-07-20 13:25 ` Nguyen Thai Ngoc Duy
@ 2011-07-20 16:12 ` J. Bakshi
2011-07-21 3:20 ` Nguyen Thai Ngoc Duy
2011-07-21 18:17 ` Jakub Narebski
1 sibling, 1 reply; 9+ messages in thread
From: J. Bakshi @ 2011-07-20 16:12 UTC (permalink / raw)
To: Nguyen Thai Ngoc Duy; +Cc: git@vger.kernel.org
On Wed, 20 Jul 2011 20:25:55 +0700
Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
> On Wed, Jul 20, 2011 at 7:54 PM, J. Bakshi <joydeep@infoservices.in> wrote:
> > As a result whenever there is a commit , it updates the related folder in filesystem.
> > Say a commit at svn->mysite-repo->dir1->trunk->src ==> modify ==> /var/www/demo/dir1
> >
> > Can I do the same in git with multiple worktree ? possible ?
>
> Using multiple worktree with the same repo won't work in git because
> the repo also have worktree-related information. But you can create a
> central, bare repository, then make several clones from that. Each one
> is checked out with different branches. You work on a clone and push
> to the central repo. The post-commit hook in the central repo will do
> pull from it, for example
>
> for site in dir1 dir2 dir3; do
> cd /var/www/$site && /usr/bin/git pull
> done
>
Thanks for your response. I am afraid that I can't understand the approach clearly but I must say that I am hopeful to see a direction.
Obviously there will be a central git repo which will have its worktree under htdocs at the same server. That's why the post-receive
hook will update the website after each push. But the issue is mapping the structure at git which is different than the structure at
filesystem. And a push should reflect to its correct folder only.
[git]->[mysite]->dir1/trunk/src => physically map => htdocs/demo/dir1
[git]->[mysite]->dir2/trunk/src => physically map => htdocs/demo/dir2
Please tell me with little more clarification, how can I do this ?
-with kind regards
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: can I use multiple worktree in same git repo ?
2011-07-20 16:12 ` J. Bakshi
@ 2011-07-21 3:20 ` Nguyen Thai Ngoc Duy
2011-07-21 6:07 ` J. Bakshi
0 siblings, 1 reply; 9+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2011-07-21 3:20 UTC (permalink / raw)
To: J. Bakshi; +Cc: git@vger.kernel.org
On Wed, Jul 20, 2011 at 11:12 PM, J. Bakshi <j.bakshi@unlimitedmail.org> wrote:
> Thanks for your response. I am afraid that I can't understand the approach clearly but I must say that I am hopeful to see a direction.
> Obviously there will be a central git repo which will have its worktree under htdocs at the same server.
No, the central repository does not need worktree attached (in other
words "bare repository"). You modify in a clone from it and push
to/pull from it.
> That's why the post-receive
> hook will update the website after each push. But the issue is mapping the structure at git which is different than the structure at
> filesystem. And a push should reflect to its correct folder only.
>
> [git]->[mysite]->dir1/trunk/src => physically map => htdocs/demo/dir1
> [git]->[mysite]->dir2/trunk/src => physically map => htdocs/demo/dir2
>
>
> Please tell me with little more clarification, how can I do this ?
OK, let's create a central repository
GIT_DIR=/somewhere/safe/repo.git git init --bare
Then clone it where development happens
git clone /somewhere/safe/repo.git ~/dev
cd ~/dev
Now we create "dir1" and "dir2" branches, correponding to what you
have in the original tree
git checkout -b dir1
# put contents of dir1/trunk/src here, commit
git checkout -b dir2 master
# put contents of dir2/trunk/src here, commit
Then we push everything back to central repo
git push origin +dir1:dir1 +dir2:dir2
Then we clone it to demo sites
cd /var/www
git clone /somewhere/safe/repo.git dir1
git checkout dir1
cd /var/www
git clone /somewhere/safe/repo.git dir2
git checkout dir2
Now you can add a post commit hook to /somewhere/safe/repo.git to move
to /var/www/dir[12] and do a "pull". When you push again from ~/dev,
/var/www/dir[12] should get updated. Is that what you want?
--
Duy
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: can I use multiple worktree in same git repo ?
2011-07-21 3:20 ` Nguyen Thai Ngoc Duy
@ 2011-07-21 6:07 ` J. Bakshi
0 siblings, 0 replies; 9+ messages in thread
From: J. Bakshi @ 2011-07-21 6:07 UTC (permalink / raw)
To: Nguyen Thai Ngoc Duy; +Cc: git@vger.kernel.org
On Thu, 21 Jul 2011 10:20:13 +0700
Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
> On Wed, Jul 20, 2011 at 11:12 PM, J. Bakshi <j.bakshi@unlimitedmail.org> wrote:
> > Thanks for your response. I am afraid that I can't understand the approach clearly but I must say that I am hopeful to see a direction.
> > Obviously there will be a central git repo which will have its worktree under htdocs at the same server.
>
> No, the central repository does not need worktree attached (in other
> words "bare repository"). You modify in a clone from it and push
> to/pull from it.
>
> > That's why the post-receive
> > hook will update the website after each push. But the issue is mapping the structure at git which is different than the structure at
> > filesystem. And a push should reflect to its correct folder only.
> >
> > [git]->[mysite]->dir1/trunk/src => physically map => htdocs/demo/dir1
> > [git]->[mysite]->dir2/trunk/src => physically map => htdocs/demo/dir2
> >
> >
> > Please tell me with little more clarification, how can I do this ?
>
> OK, let's create a central repository
>
> GIT_DIR=/somewhere/safe/repo.git git init --bare
>
> Then clone it where development happens
>
> git clone /somewhere/safe/repo.git ~/dev
> cd ~/dev
>
> Now we create "dir1" and "dir2" branches, correponding to what you
> have in the original tree
>
> git checkout -b dir1
> # put contents of dir1/trunk/src here, commit
> git checkout -b dir2 master
> # put contents of dir2/trunk/src here, commit
>
Just here, just here... The git should have dir1/trunk/src which should update /var/www/demo/dir1
and dir2/trunk/src which should update /var/www/demo/dir2
Thanks for your detailed clarification, very nice....
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: can I use multiple worktree in same git repo ?
2011-07-20 13:25 ` Nguyen Thai Ngoc Duy
2011-07-20 16:12 ` J. Bakshi
@ 2011-07-21 18:17 ` Jakub Narebski
2011-07-21 18:22 ` Fredrik Gustafsson
1 sibling, 1 reply; 9+ messages in thread
From: Jakub Narebski @ 2011-07-21 18:17 UTC (permalink / raw)
To: Nguyen Thai Ngoc Duy; +Cc: J. Bakshi, git@vger.kernel.org
Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:
> On Wed, Jul 20, 2011 at 7:54 PM, J. Bakshi <joydeep@infoservices.in> wrote:
> > As a result whenever there is a commit , it updates the related folder in filesystem.
> > Say a commit at svn->mysite-repo->dir1->trunk->src ==> modify ==> /var/www/demo/dir1
> >
> > Can I do the same in git with multiple worktree ? possible ?
>
> Using multiple worktree with the same repo won't work in git because
> the repo also have worktree-related information. [...]
[...]
> Also have a look at git-new-workdir in contrib directory of git
> repository. I don't use it but you might find it useful.
Actually with git-new-workdir you can have multiple working
directories associated with single repository, by the way of symlinks.
Note however that if you intend to *work* in those workdirs, they
better correspond to different branches... or you can mess something
heavy.
--
Jakub Narebski
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: can I use multiple worktree in same git repo ?
2011-07-21 18:17 ` Jakub Narebski
@ 2011-07-21 18:22 ` Fredrik Gustafsson
2011-07-21 18:50 ` Jakub Narebski
0 siblings, 1 reply; 9+ messages in thread
From: Fredrik Gustafsson @ 2011-07-21 18:22 UTC (permalink / raw)
To: Jakub Narebski; +Cc: Nguyen Thai Ngoc Duy, J. Bakshi, git@vger.kernel.org
On Thu, Jul 21, 2011 at 11:17:57AM -0700, Jakub Narebski wrote:
> Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:
>
> > On Wed, Jul 20, 2011 at 7:54 PM, J. Bakshi <joydeep@infoservices.in> wrote:
> > > As a result whenever there is a commit , it updates the related folder in filesystem.
> > > Say a commit at svn->mysite-repo->dir1->trunk->src ==> modify ==> /var/www/demo/dir1
> > >
> > > Can I do the same in git with multiple worktree ? possible ?
> >
> > Using multiple worktree with the same repo won't work in git because
> > the repo also have worktree-related information. [...]
> [...]
> > Also have a look at git-new-workdir in contrib directory of git
> > repository. I don't use it but you might find it useful.
>
> Actually with git-new-workdir you can have multiple working
> directories associated with single repository, by the way of symlinks.
>
> Note however that if you intend to *work* in those workdirs, they
> better correspond to different branches... or you can mess something
> heavy.
It would be possible to use the .git-file feature here. Then symlinks are
avoided and the solution is portable.
Med vänliga hälsningar
Fredrik
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: can I use multiple worktree in same git repo ?
2011-07-21 18:22 ` Fredrik Gustafsson
@ 2011-07-21 18:50 ` Jakub Narebski
2011-07-22 9:06 ` Sergio
0 siblings, 1 reply; 9+ messages in thread
From: Jakub Narebski @ 2011-07-21 18:50 UTC (permalink / raw)
To: Fredrik Gustafsson; +Cc: Nguyen Thai Ngoc Duy, J. Bakshi, git
On Thu, 21 Jul 2011, Fredrik Gustafsson wrote:
> On Thu, Jul 21, 2011 at 11:17:57AM -0700, Jakub Narebski wrote:
> > Actually with git-new-workdir you can have multiple working
> > directories associated with single repository, by the way of symlinks.
> >
> > Note however that if you intend to *work* in those workdirs, they
> > better correspond to different branches... or you can mess something
> > heavy.
>
> It would be possible to use the .git-file feature here. Then symlinks are
> avoided and the solution is portable.
Actually it wouldn't. Each new workdir has a separate HEAD and a
separate index; it is contents of .git that is symlinked, not .git
itself.
--
Jakub Narebski
Poland
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: can I use multiple worktree in same git repo ?
2011-07-21 18:50 ` Jakub Narebski
@ 2011-07-22 9:06 ` Sergio
0 siblings, 0 replies; 9+ messages in thread
From: Sergio @ 2011-07-22 9:06 UTC (permalink / raw)
To: git
Jakub Narebski <jnareb <at> gmail.com> writes:
>
> On Thu, 21 Jul 2011, Fredrik Gustafsson wrote:
> > On Thu, Jul 21, 2011 at 11:17:57AM -0700, Jakub Narebski wrote:
>
> > > Actually with git-new-workdir you can have multiple working
> > > directories associated with single repository, by the way of symlinks.
> > >
> > > Note however that if you intend to *work* in those workdirs, they
> > > better correspond to different branches... or you can mess something
> > > heavy.
> >
> > It would be possible to use the .git-file feature here. Then symlinks are
> > avoided and the solution is portable.
>
> Actually it wouldn't. Each new workdir has a separate HEAD and a
> separate index; it is contents of .git that is symlinked, not .git
> itself.
>
Is there any means to separate worktree info from the object repository? E.g.,
having a .git dir identical to that of a bare repo and a .git_workdir dir with
the head, head logs, index and all what makes a nonbare repo different from a
bare one? That might make it easier to transform a repo from bare to nonbare in
addition to simplifying the logic of git-new-workdir.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-07-22 9:07 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-20 12:54 can I use multiple worktree in same git repo ? J. Bakshi
2011-07-20 13:25 ` Nguyen Thai Ngoc Duy
2011-07-20 16:12 ` J. Bakshi
2011-07-21 3:20 ` Nguyen Thai Ngoc Duy
2011-07-21 6:07 ` J. Bakshi
2011-07-21 18:17 ` Jakub Narebski
2011-07-21 18:22 ` Fredrik Gustafsson
2011-07-21 18:50 ` Jakub Narebski
2011-07-22 9:06 ` Sergio
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).