2

and thank you for taking the time to read my post.

I am currently working with Unity Engine - which requires certain files to be in certain folders within the project directory. For example, lets say I have this hypothetical project - LameGame. My folders would look like this

./LameGame  
./LameGame/Assets  
./LameGame/Assets/Resources  
./LameGame/Assets/Editor  
./LameGame/Assets/Plugins  
./LameGame/Assets/Scripts

I maintain a few different plugins for Unity Engine via git and was wondering if there was a way to import them all into the same project as submodules. The problem I'm running into is that they cannot all have a unique directory - they need to be spread between the directories like so:

PluginA

/Assets/Resources/PluginA/*
/Assets/Editor/PluginA/*
/Assets/Plugins/PluginA/*

PluginB

/Assets/Resources/PluginB/*
/Assets/Editor/PluginB/*
/Assets/Plugins/PluginB/*

So ideally what I'm looking for is a solution that allows my main project, as well as the plugins to all stem from the Assets/ folder. Is this possible with Git?

Thank you in advance for any input/feedback/suggestions!

(Note: I use Windows 7 primarily with TortoiseGit)

Paŭlo Ebermann
  • 73,284
  • 20
  • 146
  • 210
Kyle
  • 45
  • 1
  • 5

3 Answers3

2

I would rather:

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • There can be some issues with symlink (https://code.google.com/p/msysgit/issues/detail?id=432, http://code.google.com/p/msysgit/issues/detail?id=520) but nothing which would actually prevent you to use them. – VonC May 17 '11 at 19:10
1

While very much deprecated, and I mean very, in theory you could have a git alias which provides the --git-dir argument to support a remote .git directory for one of the repositories. You could then add all of the files in first repo in the second's .gitignore and vis-versa. You could then "git commit" to commit into the first repository and "altgit commit" to commit into the second.

You are better off using a symlink tree as others have suggested, but it technically would work.

Seth Robertson
  • 30,608
  • 7
  • 64
  • 57
  • Why is this deprecated? – einpoklum Apr 03 '17 at 22:27
  • @einpoklum: It violates the [principal of least surprise/astonishment](https://en.wikipedia.org/wiki/Principle_of_least_astonishment). Someone unaware of your configuration, someone with too little sleep, or an automated tool using find .git or something could do bad things to your directory or repos. Consider the nightmare of accidentally getting two git repos trying to manage the same file if those repos might be updated via external processes. Just say no. – Seth Robertson Apr 04 '17 at 03:48
  • Hey, it's a revision control system - I can undo those bad things :-) – einpoklum Apr 04 '17 at 08:46
  • @einpoklum Not necessarily when you `git clean -dfx` with uncommitted changes for the other repo. – Seth Robertson Apr 04 '17 at 23:03
0

I think you're looking for this: http://book.git-scm.com/5_submodules.html

It explains exactly how to set up submodules in Git, complete with examples

rlc
  • 2,808
  • 18
  • 23
  • Thank you for the quick response. The issue I'm having is that submodules seem to require their own folder (in this case git/a, git/b, git/c, and git/d) but I need them to all share the same folder (git - or in my case, Assets/). I'm thinking this may just not be possible. – Kyle May 17 '11 at 18:25
  • 1
    The page I pointed to also explains what you *can't* do with Git submodules. What you're looking for can only be done with trickery, such as by using symlinks to build the tree you want... – rlc May 18 '11 at 12:55