Re: can I use multiple worktree in same git repo ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 20, 2011 at 11:12 PM, J. Bakshi <j.bakshi@xxxxxxxxxxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]