On Wed, Feb 10, 2010 at 12:50:19AM -0300, stefano wrote:
> > On Mon, Feb 08, 2010 at 07:37:02PM -0800, stefano wrote:
> >> I a n00b using GIT, i have some questions about how yo use git with
> >> two repositories
> >>
> >> I'm going to use cakephp (1.3 branch) . cakephp have is own repository
> >> in github.com (git://github.com/cakephp/cakephp1x.git)
> >>
> >> I need switch the branch to get the version 1.3 so this are my
> >> commands
> >>
> >> git clone git://github.com/cakephp/cakephp1x.git
> >> git branch --track 1.3 origin/1.3
> >> git checkout 1.3
> >>
> >> We this commands a got some folders like cake, app, vendors and some
> >> files index.php and .htaccess (in my root folder).
> >>
> >> In the folder "app" i have all my source. I wanna control this folder
> >> i my own git repository and snyc the folder "cake" with the info of
> >> cakephp's repository (in svn i use svn externals cake http://repository
> >> to do that but now i'm lost in git)
> 
> [...]
> 
> On Tue, Feb 9, 2010 at 2:09 PM, Petr Baudis <pa...@ucw.cz> wrote:
> >
> >  What you are trying to do is not the usual mode of operation in Git;
> > normally, the whole tree is always in a single repository. Please
> > rethink if you really need multiple repositories.
> 
> [...]
> 
> Petr
> 
> I wanna use multiple repositories only to get the last version of
> cakephp (they use github)
> 
> S.

Hello

Stefano, please pay close attention to what you wrote:

> We this commands a got some folders like cake, app, vendors and some
> files index.php and .htaccess (in my root folder).
>
> In the folder "app" i have all my source. I wanna control this folder

This is not tenable, regardless of whether you use git or svn
externals.  You have an "app" directory, and so does the
upstream project.  If upstream didn't have this directory then
it'd be easier.  It would be possible if you made cakephp a
subdirectory of -your- project, not the other way around, which
lets you use submodules or git-subtree.  In any case, there's
always a way.

Now, pay close attention to what Petr wrote -- it was a very
subtle but important suggestion:

> What you are trying to do is not the usual mode of operation in Git;
> normally, the whole tree is always in a single repository. Please
> rethink if you really need multiple repositories.

You do not need a seperate repository.  What you need is a
separate branch for your stuff. e.g.:

-- o 1.3 -- o -- o -- o
    \
     `-- o -- o -- o your_branch


All of your changes to the app/ directory happen in your branch.
Every so often you'll want to update with the latest to
upstream.  The easiest way to do this is to have a remote called
"upstream" pointing at github and periodically merge their stuff
into your branch..


git init
git remote add upstream git://servername/path.git
git fetch upstream
git reset --hard upstream/1.3

You now have something like this:

--o upstream/1.3
   \
    `-- master

upstream/1.3 and master point at the same thing.
Now, you do some work in your app/ directory and make some
commits:

---o upstream/1.3
    \
     `-- o -- o -- o master


Here's how you'd go about updating to the latest cake code.
First, fetch their stuff.  This will advance the upstream/1.3
branch.

git fetch upstream

---o -- o -- o -- o upstream/1.3
    \
     `--- o -- o master

Now merge it into your branch.  This is where you'll resolve any
conflicts that may arise in the app/ directory.  This brings
your files up to date with upstream.

git merge upstream/1.3

---o -- o -- o -- o upstream/1.3
    \              \
     `--- o -- o -- o - master

This is one of the simplest ways to do this given the structure
you described.  It's also superior in that you can do really
nice stuff like change the cakephp framework if you need to.

You can then do things like "what did I change in foo?"

git diff origin/1.3 -- foo.py

Branches are git's specialty so you'll gain a lot from doing
things this way.

-- 
                David

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to git-us...@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.

Reply via email to