Search code examples
phpgitclonecloning

Git - Few git repos clones and what not (PHP - framework Lithium, ORM Doctrine 2)


I'm fairly new to git (vcs in general) so I need help with this next case.

I want to start working on a new project, which will be built using php lithium framework, and doctrine 2.

Case:

  • I have a main project git repository, and now I want to add (clone) lithium framework inside, from github.

  • Next, I need to clone li3 extension for doctrine 2 (it automatically clones itself and doctrine 2).

Questions:

  1. Is this the right way (I suppose not).
  2. How do you manage cloning inside existing repository (especially that second part, with li3 extension and doctrine 2).

Thanks in advance.


Solution

  • In git there is no such "cloning inside existing repository" (well technically there is but let's don't make this more complicated than needed). What you describe looks like that you want to use the lithium framework and doctrine as a library.

    Normally you don not need to put external libraries into your repository. You only need to do this if you plan to modify the library code and put it under version control.

    But you should think first about what you would like to do: integrate it into the repository or not. I think the later is the easier one.

    You just create your own git repository first. Then you exclude that part of the library folder that you don't want to have under version control. So you can keep things apart quite easily in the beginning.

    To set this up, first create your project on disk w/o git. Create the file system and directory layout. Then initialize the git repository within the project's main directory. That's just calling git init inside that directory.

    Git will now show the status of all files you have in there when you type git status. Before you do the first commit you can use the methods described in gitignore(5) Manual Page to exclude the libraries and (perhaps configuration files of your IDE) that you do not want to have inside the git repository.

    You can always check if the configuration you're editing matches your need by checking the output of git status.

    Keep in mind that git ignores empty directories, so if there is a folder you don't want to be added, it will start to show in the status only if it contains at least a file.

    When all the files you don't want to have under version control have disappeared from the status listing, you can do your first commit: git commit -m "Initial Commit.".

    Depending if you have configured git or not, it will give you an error about your name and email. The error messages point you to what you need to know. It's just that you have an author and email for each commit, which is useful.

    And that's it already. Check the web for the commands:

    • git init
    • git status
    • git commit

    it's quite easily with git help *command*, like git help init. It takes some time to learn git, so probably create some test-repository to play around. Once you've learned the commands and get used to it (in case of doubt, google your problem), it's supercool to use.