Portponky / better-terrain

Terrain plugin for Godot 4
The Unlicense
433 stars 21 forks source link

Usage as Git submodule #81

Closed nihiluis closed 2 months ago

nihiluis commented 2 months ago

How do I add this as a git submodule? The directory structure makes it go into the root directory of my project that already has a Git config.

Portponky commented 2 months ago

The repo is arranged with this folder structure to support Godot asset library. Git doesn't let you pull a subdirectory of a submodule only. However, there is a workaround.

From the project directory, make an addons directory and a submodules directory. Add a .gdignore file to the submodule directory so that godot ignores it. Check out your submodule in there. Then, use a symbolic link to make the plugin directory appear in the addons folder.

If you're on Windows or cannot use symbolic links for whatever reason, you could instead add a .gitignore to the addons directory, then make a git hook to copy the submodule folder over after it has been pulled/updated.

nihiluis commented 2 months ago

Hmm, not ideal. Thank you, I was hoping for something more convenient.

Renari commented 1 month ago

@nihiluis I recommend using godotenv I've found it to be an very nice way to manage addons, that doesn't require you commit all of the addon code to your repo.

For example:

// Godot addons configuration file for use with the GodotEnv tool.
// See https://github.com/chickensoft-games/GodotEnv for more info.
// -------------------------------------------------------------------- //
// Note: this is a JSONC file, so you can use comments!
// If using Rider, see https://youtrack.jetbrains.com/issue/RIDER-41716
// for any issues with JSONC.
// -------------------------------------------------------------------- //
{
  "$schema": "https://chickensoft.games/schemas/addons.schema.json",
  // "path": "addons", // default
  // "cache": ".addons", // default
  "addons": {
    "imrp": { // name must match the folder name in the repository
      "url": "https://github.com/MakovWait/improved_resource_picker",
      // "source": "remote", // default
      // "checkout": "main", // default
      "subfolder": "addons/imrp"
    },
    "better-terrain": { // name must match the folder name in the repository
      "url": "https://github.com/Portponky/better-terrain",
      // "source": "remote", // default
      // "checkout": "main", // default
      "subfolder": "addons/better-terrain"
    }
  }
}