Skip to main content

Git SubModule vs Git SubTree

Git Sub Module

Upload In ProgressUntitled

Pros

  • Has UI on Source Tree
  • Your package project is separated from main project
  • Everyone on the project has reference to submodule
  • quicker and faster contribution capability

Cons

  • May forget to push changes
  • Need to download another submodule project
  • soft link that can be broken when module repository are deleted

Git Subtree

Thre red line below is from Git Subtree. History is visible.

Untitled

Pros Git Subtree

  • Your package history tree is visible on main project
  • Works well if you want to extract/ export a folder to another Git Url
  • no additional complexity after addition
  • no dependency nor linking to module repository

Cons

  • Git User Interface can’t help with implementation (Require Git Bash CLI)
  • require better understanding on git commits and tree structure (graph with multiple root)
  • the need of working with multiple remote url in 1 repository
  • slower and harder way to push back and contribute to module repository

Conclusion

  • Git submodule is simpler when you use shared packages & want to contribute. Your main project history is still clear
  • Git subtree works well when you only want to use the package as is adding it to the project and rarely want to push back to module repository.