Repareman Repareman - 1 year ago 117
Git Question

Symbolic Link git Submodule To Reference Files

So here is what I'm trying to do. I have a Unity 3D project for my reusable code. And I want to add this to my other projects that I house in git.

So let's say I have a project 'foo'.

I want to clone foo and then add my reusable scripts as a sub-module;

then I want a symbolic link to the folder that contains all the reusable scripts in my sub-module and one that exists in project foo's asset folder.

So when I make a change in my project, I could push my changes to my sub-module project.

This is probably very confusing, please let me know if I need to be more specific and I will try to do better.

Answer Source

It is best to separate the two environments:

  • the git clone one, where you have foo and foo/script submodule:

    git clone foo /url/of/foo
    git submodule add /url/of/script
    git add .
    git commit -m "Add script as submodule of foo"
    git push
  • the working environment, where you set your symlinks to foo and script scripts.

    cd somewhere/else
    ln -s /path/to/foo/file1
    ln -s /path/to/foo/scripts/scrip1

That way, once you have modified scripts, you can go back in foo, and do a git push --recurses-submodules=check, in order to make sure you have added/push both foo/scripts and foo.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download