1

Scenario: I have a Unity (the game engine) project that builds to Windows, Android and iOS. A few folders are only relevant for Windows and should be out of the project for the Android and iOS versions. Unity does not offer a good way of doing this, so I have three clones of the project (on different machines), with those folders removed.

The problem with this approach: Sometimes, I'll make changes in one of the clones but there are about 16K "changed" (actually deleted) files, making it pretty hard to find the actually changed files in GitHub for Desktop (I also use TortoiseGit but that has the same issue).

Using .gitignore? Nope: At first I tried using .gitignore - but that's designed for actually ignoring the files, i.e. not version controlling them. Doesn't help for my use case because I want those files version controlled, and certainly not deleted in the repository.

Using branches: Probably would work if I committed the delete in the branch but it would mean I'd have to merge all changes in the main branch to the branch where the folders are deleted all the time, so that seems rather cumbersome for what I need (unless I'm missing something).

Using .git\info\exclude: Maybe I just did something wrong but it didn't hide the deleted files, either. I'm assuming this is also for actually excluding the files from version control (so the deleted files still show up). But what I want is keeping the files in version control and just hiding them from view.

I have seen Ignore deleted files in git?, which recommends splitting the repo. This seems fairly close to what I need but still feels like using a sledge-hammer to crack a nut.

So ... How can I hide (not ignore) deleted files in one clone?

Jashan
  • 220
  • 2
  • 9

3 Answers3

1

Staying within GIT realm, you can have a core (all common files) project as subrepository that is embedded within build target specific repos. This way every pushed change to the core will get pulled as a submodule change to your branches

zambari
  • 4,797
  • 1
  • 12
  • 22
  • Cool, thank you! I just found out about Sparse Checkout (see my own answer), which seems to do what I need - but it's good to know about core projects / submodules. – Jashan Jul 09 '18 at 10:43
1

Apparently, the way to do this is using sparse-checkout, see also Sparse Checkout.

It's a good idea to set this up before checking everything out and not wildly trying git commands to fix not having it done that way when you don't know what you're doing, especially if you're working with a game project with GBs of Assets, like I just did (git read-tree --empty was not a good friend of mine). GitHub Desktop also started throwing errors at me until I did a git reset / git checkout which is probably what I should have done in first place.

Now, everything seems to be the way it should ... I just got a little scared along the way (and probably wasted and hour or two, under tight deadline where it really hurts).

EDIT: I posted the full solution to exclude folders from the project for specific build configurations for my specific case here on the Unity Forums.

Jashan
  • 220
  • 2
  • 9
0

Another way but not convenient with Unity3d, it's using CMake.

It's permits you to make automatic rules to generate different executables with same or different sources files in only one repository like this :

add_executable(binary_name1 source1 source2 source3 ...) add_executable(binary_name2 source1 source2 source4 ...) add_executable(binary_name3 source3 source4 ...) ...

So, you can choose to not use your Windows sources files when compiling Android and iOS versions.

CMake's official website : https://cmake.org/

EDIT: Maybe a Cmake integration for Unity ?

Sunchock
  • 361
  • 4
  • 14
  • Thank you, but Unity has its own build-engine that processes all assets in the project, so CMake unfortunately won't help with that. I'm editing the question to be a bit more clear about that. – Jashan Jul 09 '18 at 09:31
  • 1
    I understand, sorry for not being able to help you anymore! – Sunchock Jul 09 '18 at 09:49