Using Git Sub Modules to manage 3rd party dependencies?

I’m currently running a test to see how Git sub modules work in the hope that I can use them to manage 3rd party dependencies.

In my local test I have a folder with my main Git repo in it. I then have a sub folder called scripts which has a sub module created for the GitHub repo https://github.com/jrburke/requirejs/

  • How two users can make git pull in same local git path?
  • Is there Environment variable for Amazon ElasticBeanstalk containers for the deployed version?
  • Introduction to Git and practical usage patterns
  • Custom git diff to ignore some conflicts
  • Copy directory from another branch
  • Getting the list of changed files from a commit in JGit
  • When I initially set-up the sub module I obviously got ALL the files/folders within that 3rd party repo but the only file I was interested in was the require.js file (https://github.com/jrburke/requirejs/blob/master/require.js) I commited my changes including all redundant files/folders deleted and then waited for RequireJs to make a change to their code.

    When the change happened I git pulled in and it seems that every file changed would get pulled down? Even though in my repo I had commited them as deleted it seems that the sub module would regardless pull down any files that had changed even though I clearly didn’t want them.

    So that is problem one. The second problem is I then delete the files again and go to commit but I can’t commit because of merge issues? But I can’t merge them because I’ve deleted them! I’ve seen this before and apparently the solution was to go into a specific .git folder and delete out the files so they couldn’t be referenced but this just seems like a lot of work to manage 3rd party dependencies?

    I just want to clone down a repo, delete any files I don’t want and run a git pull whenever I hear about an update to the 3rd party code. Is there any way to achieve that, simply?

  • How to ignore one file in gitignore while unignoring its parent folder
  • How to get “their” changes in the middle of conflicting Git rebase?
  • how to update git client to overcome the latest vulnerability?
  • Xcode bot: git submodules not initialized
  • GIT client for AIX 6.1+
  • How To Not ignore based on keyword in .gitignore
  • One Solution collect form web for “Using Git Sub Modules to manage 3rd party dependencies?”

    When the change happened I git pulled in and it seems that every file changed would get pulled down?

    Sure it does: your parent repo still has a reference to the upstream jrburke/requirejs repo with a SHA1 referencing its full content.

    If you really wanted to managed a modified version of that repo as a submodule, you would need to:

    • fork that repo
    • add your fork as a submodule
    • remove all files but one
    • git commit within that submodule, and push to your fork
    • add as a new remote named ‘requirejs’, pointing to jrburke/requirejs repo
    • get back to your parent repo and commit again (to record the new state of your submodule)

    Then, within the submodule, you can ‘git fetch requirejs‘, merge only the file that interest you to your own version, commit and push that to your fork.
    As always, don’t forget to go back to your parent repo, and commit again.

    Git Baby is a git and github fan, let's start git clone.