Git: How to handle git libraries in project

前端 未结 2 784
星月不相逢
星月不相逢 2021-01-31 04:22

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 re

2条回答
  •  抹茶落季
    2021-01-31 05:18

    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 git@github.com: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"
    

提交回复
热议问题