Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Git to have different working directory structures on different platforms?

Tags:

git

On Windows we have root\folder1, root\folder2, root\folder3. On Linux we have root/folder1/folder2, root/folder1/folder3

I would strongly prefer NOT to use submodules nor subtreees.

Is there another solution? Would it work to create a branch and re-arrange the files to the Linux structure? And would merges between the branches make sense?

Edit

I have done much more reading, especially about branch work flows. I'm now re-considering the NOT submodules statement. I was concerned with having the day-to-day developer repository containing submodules and the complications that seems to entail. But, I think that the developers do not need submodules, they can meet the need with embedded repositories.

Say folder 1, folder 2 and folder3 are separate git repositories - repo 1, repo 2 and repo 3. On Windows the 3 repositories are separate. On Linux, folder 1 is repo 1, folder1/folder 2 is repo 2, etc.

If I'm in folder 1 and there are changes in folder 2, will a git add . not include the folder2 change? Does git stop when it sees another .git?

There could be 2 separate bare repositories for building which includes the 3 repos as submodules in the appropriate configuration for Windows and Linux. The release branches can then be managed here. But what branching is seen in repo 1, 2 and 3? Has anyone tried something like this? Did it work well?

like image 814
RobG Avatar asked Nov 19 '25 17:11

RobG


1 Answers

Beside the symlinks mentioned by mvp (note: you can have symlink on Windows 7+ too, see also "Git Symlinks in Windows"), this would be a deployment issue:

Ie: you would have:

  • your regular local clone
  • a copy of that clone with the right structure
  • a way to diff/import any modification made in that copy back into the regular git repo

... so yes, keeping a common directory structure remains the simplest solution.


If I'm in folder 1 and there are changes in folder 2, will a git add . not include the folder 2 change?

No, it will only consider changers in any part of folder 1, except folder 2 content.

Does git stop when it sees another .git?

Exactly.

There could be 2 separate bare repositories for building which includes the 3 repos as submodules in the appropriate configuration for Windows and Linux

Note: a bare repo cannot contain another repo, since there is no working tree for said repo to include... anything.

A nested repo wouldn't be recorded at all in a branch of a parent repo, contrary to a submodule.


I suspect subtree is a better fit for us.

Yes, subtree (part of git since 1.7.11) would involve 2 repos: one for Windows and one for Linux.
Each one would aggregate subtree repos with the right structure.

like image 81
VonC Avatar answered Nov 21 '25 06:11

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!