Git using subtree or submodule to manage external resources

I read much about how awful the git submodule is supposed to be, but I am not sure if that is just the groaning of people who feel it limits or if it has serious issues (especially concerning my use case).

I just want to include different repos into my repo like this

  • Does SmartGit support git-svn?
  • npm git protocol dependencies
  • What would I use git-worktree for?
  • How to revert project back to a previous commit in android studio
  • git ignore all files of a certain type, except those in a specific subfolder
  • Textmate git commands fail with 'sh: line 1: git: command not found'
  • website/
     libs/
      js/
       fs-slides [external]
       fs-dialog [external]
    

    and have to possibility to update those repos easily. As far as I understand there is no easy possibility of including just one file from a repo, right? (But that’s okay.)

    Should I use submodules for this?
    Or are there any problems with it? Or is subtree much easier?

  • Synchronize git workspace with another folder
  • How to do git commits in Emacs buffers
  • clojure and leiningen - using a git repository as dependency
  • Git red remote branches
  • Git is not using the contents of .gitignore
  • How do I recover/resynchronise after someone pushes a rebase or a reset to a published branch?
  • One Solution collect form web for “Git using subtree or submodule to manage external resources”

    Submodule is well-suited to your case, especially since you don’t mind included those subrepos in their own subdirectory.

    The main serious issue you could have using submodules is when updating them while having updates in progress, as described in “how exactly does git submodule work”:

    If you forget to set a branch when making commits in a submodules, said commits will be made on a detached HEAD, and those changes in progress will be lost at the next git submodule update (you can get them back through the reflog, if activated for your submodule repo).

    Then, as Michael comments, and as I detail in the link above, you need to push the submodule to its own upstream before commit and pushing the parent repo (to avoid pushing unpublish submodule commits)

    Git Baby is a git and github fan, let's start git clone.