Skip to content

Instantly share code, notes, and snippets.

@joprice
joprice / git-subtree-basics.md
Created December 29, 2019 21:15 — forked from SKempin/Git Subtree basics.md
Git subtree basics

Git Subtree Basics

If you hate git submodule, then you may want to give git subtree a try.

Background

When you want to use a subtree, you add the subtree to an existing repository where the subtree is a reference to another repository url and branch/tag. This add command adds all the code and files into the main repository locally; it's not just a reference to a remote repo.

When you stage and commit files for the main repo, it will add all of the remote files in the same operation. The subtree checkout will pull all the files in one pass, so there is no need to try and connect to another repo to get the portion of subtree files, because they were already included in the main repo.

Adding a subtree

Let's say you already have a git repository with at least one commit. You can add another repository into this respository like this:

@joprice
joprice / abvsTypeDep.scala
Last active December 21, 2015 22:59 — forked from kailuowang/abvsTypeDep.scala
Abstract Type vs Type parameter
trait AnimalMouth
class Beak extends AnimalMouth
object Test1 {
//================================Generic type works as in the following =======================
trait Animal[Mouth <: AnimalMouth] {
def mouth : Mouth