Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: How to handle git libraries in project

Tags:

I've a Xcode project which itself has Git Source Control. In a Libraries folder I've cloned eight other Git project from GitHub. They are located inside my own Git repository and I've added all these libraries to my git in a commit.

Instead of having the code of all these git libraries in my repository, is there a way to let git download their code from their repo when I make a clone of my repo? Or is it normal to include other git repos inside a project?

like image 655
dhrm Avatar asked Jan 17 '12 15:01

dhrm


People also ask

How do I manage a git repository?

Create and Manage a Git RepositoryClick on the Settings page for your account, then on the SSH and GPG Keys section. On that page, click the “New SSH key” button. After you have clicked on the New SSH key button a panel will appear in which you should then input a Title for the key and the private key itself.


1 Answers

Sure do the following:

  1. Remove the 3rd-party-folder which you might have added already
  2. Open your Terminal and execute the following commands

    cd /path/to/your/main/repo git submodule add [email protected]:someuser/somerepo.git somerepo git commit -m "Added submodules" 
  3. Now instead of copying those files you'll have a reference to the other repository in your project:

Edit:

Now if you want to update the submodule to a more recent commit you can do the following:

cd somerepo git pull # You can also checkout a branch / tag etc. cd .. git add somerepo git commit -m "Telling the main repo to update the reference to the referenced repo" 
like image 56
Besi Avatar answered Sep 24 '22 14:09

Besi